[EMAIL PROTECTED] (Alexander Zatvornitskiy) writes: > Привет Marc! > > 16 мая 2005 в 22:18, Marc 'BlackJack' Rintsch в своем письме к All писал: > > MR> That clears only one dictionary at class level. Which is visible on > MR> both instances. > > MR> class Distribution: > MR> def __init__(self): > MR> self.__gr_on_transp = dict() > MR> self.__ostatok_m = dict() > MR> ... > > MR> This creates *instance variables* which should be deepcopied > MR> without problems. > Hmm. I don't find definition of "class variable" in manual. I try to test it > on > such a simple test and find that such variable is NOT shared between copies:
Actually, it is shared - but only for reference. If you assign to it, you'll create an instance variable of the same name. As Peter explained, if you remove the instance variable, the class variable becomes visible again. Try this: py> class C: ... q = [] ... py> c1 = C() py> c2 = C() py> c3 = C() py> c1.q.append(1) py> c2.q.append(2) py> c3.q.append(3) py> c1.q, c2.q, c3.q ([1, 2, 3], [1, 2, 3], [1, 2, 3]) py> <mike -- Mike Meyer <[EMAIL PROTECTED]> http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. -- http://mail.python.org/mailman/listinfo/python-list