[Tutor] classes and the deepcopy function

bob gailer bgailer at alum.rpi.edu
Sun Jan 6 14:26:12 CET 2008

Michael wrote:
> Okay
> Just when I think I am getting it you throw this in. 
You're welcome.
> So why does a become local to each variable but b seem global?
A better way to ask that is "why does a become an instance property but 
b remain a class property?"

f.a = 3

This is an assignment statement. It creates a property of the instance. The class property a is ignored.


This is not an assignment. It references a property of the instance that does not exist, so Python goes up the inheritance hierarchy and finds the class property.


More information about the Tutor mailing list