i don't really understand member variables..

gabor gabor at realtime.sk
Thu Oct 24 02:54:16 CEST 2002


until now i thought i understand member variables...

but now i don't :-):

>>> class Test:
...     data = []
>>> a = Test()
>>> a.data.append("x")
>>> a.data
>>> b = Test()
>>> b.data

so they are shared?
but now:

>>> b.data = ["y"]
>>> b.data
>>> a.data

now they aren't anymore....

so if i define some data after the class... line then those are static (
as in c++?) but why the stop being static in the second code-example?

i kind of begin to understand this, but could someone clarify this?


listening to Keitaro Takanami - Morning,Morning
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20021024/c2403418/attachment.sig>

More information about the Python-list mailing list