Class initialization

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Aug 8 10:49:27 EDT 2010


On Sun, 08 Aug 2010 17:14:08 +0300, Costin Gament wrote:

> Thank you for your answer, but it seems I didn't make myself clear. Take
> the code:
> class foo:
>   a = 0
>   b = 0
> c1 = foo()
> c1.a = 5
> c2 = foo()
> print c2.a
> 5

Incorrect.

>>> class foo:
...   a = 0
...   b = 0
...
>>> c1 = foo()
>>> c1.a = 5
>>> c2 = foo()
>>> print c2.a
0



-- 
Steven



More information about the Python-list mailing list