Bugs item #1506799, was opened at 2006-06-15 13:03 Message generated for change (Settings changed) made by tim_one You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1506799&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None >Group: Not a Bug >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: SPlyer (splyer) Assigned to: Nobody/Anonymous (nobody) Summary: list bug Initial Comment: When i define class with list member(in class body, not in __init__ or other method) that list become common for all instances of the class. So when i change list member in one instance it also will changed in all the other instances. OS - Windows XP(SP2) [code] class TestClass: t = [] def __init__ (self): pass a = TestClass() b = TestClass() a.t.append(123) print b.t [/code] ---------------------------------------------------------------------- >Comment By: Tim Peters (tim_one) Date: 2006-06-15 13:14 Message: Logged In: YES user_id=31435 Closing as Not-a-Bug. That's exactly what should happen. If you want a different `t` per instance, use a different `t` per instance instead of sharing a common `t` across all instances -- you simply got what you asked for here. If that's not what you want, then, e.g., put "self.t = []" in your __init__ method. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1506799&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com