Kevac Marko <[EMAIL PROTECTED]> writes: > When changing default value, is there any way to change class > attribute and all referenced attributes too? > > class M: > name = u"Marko" > > a, b = M(), M() > a.name = u"Kevac" > print M.name, a.name, b.name > -> Marko Kevac Marko > > Is there any way to get here -> Kevac Kevac Kevac ? > Or what is the right way of keeping global variables in classes?
Simply assign to M.name instead of to a.name. Assigning to a.name creates an a-specific attribute that overrides the global one. If you insist on being able to assign to a.name to change M.name, look up "descriptors" -- but that feels like fighting the language. -- http://mail.python.org/mailman/listinfo/python-list