Could you clarify some of the ideas behind Python classes and class instances?
Consider this:
class A():
name = 'A'
a = A()
a.name = 'B'
print a.name
print A.name
prints:
B
A
if instead point 1i use the class name, the output is different:
A.name = 'B'
prints:
B
B
Even if the classes in Python were a kind of prototype for class instances, I would expect the already created instances to remain intact, i.e. are output as follows:
A
B
Can you explain what is really going on?
source
share