python class attribute
i have a question about class attribute in python.
class base : def __init__ (self): pass derived_val = 1 t1 = base() t2 = base () t2.derived_val +=1 t2.__class__.derived_val +=2 print t2.derived_val # its value is 2 print t2.__class__.derived_val # its value is 3
The results are different. I also use id() function to find t2.derived_val and t2.class.derived_val…
View On WordPress









