Variables in Python -


here little script:

class any(object):     def __init__(self,x):         self.x=x  l = [any(2),any(3),any(7),any(9),any(10)] print(len(l)) l2=[ind ind in l] l3=l print(set(l2).difference(l3)) print(l2[1]==l[1]) print(l3[1]==l[1]) del l2[1] print(len(l)) del l3[1] print(len(l)) 

why deleting instance of any in l2 doesn't change l, deleting in l3changes l although seems not have difference between l2 , l3?

thanks lot!

l2 different object created l

l3 refers same object l. changing in l or l3 affect object , therefore affect l , l3.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -