New submission from Vlad <vla...@yahoo.com>: If a class member is declared outside of a function, it's creation is _not_ repeated with every new instance of the class. Instead, the same member is created during the first instance and then shared by all the subsequent instances of that class. This is wrong, because a new member should be created for every instance.
I have attached a sample code contrasting the incorrect behavior (on top) with the correct behavior (on bottom). Python behaves correctly if the member is declared in __init__ (that is, Python initializes a new member for every instance). The output of "print b.greet" and "print d.greet" should be the same and should read "['Howdy']". ---------- files: class_member_init_inconsistency.py messages: 94851 nosy: vladc6 severity: normal status: open title: Class members not properly initialized if declared outside of function type: behavior versions: Python 2.5 Added file: http://bugs.python.org/file15253/class_member_init_inconsistency.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7254> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com