Stefan Arentz wrote:
> It is really simple. When you say b.a then the instance variable 'a'
> is looked up first. If it does not exist then a class variable lookup
> is done.

This mixing of class and instance variable might be the cause of 
confusion...

I think of it as follows:
1 When the class statement ends a class object is created which is 
filled by all the statements inside the class statement
        This means all variables and functions (methods) are created according 
to the description.
        NOTE This happens just once.
2 When an instance of the class is created, what effectively happens is 
that a shallow copy of the class object is made.
        Simple values and object references are copied.

This explains:
- why methods and complex objects (e.g. lists) are shared among 
instances of a class and the class itself
- simple values are not shared

--eric

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to