gu a écrit :
Hi to all,
i have a module (a single .py file, actually), with a class called HashedDir.

when i import the file and instanciate 2 instances of that class, when i check the object's fields they're always the same, even if the two objects should be different.

Eg:

h1 = HashedDir('someValue')
print h1.value # someValue
h2 = HashedDir('someOtherValue')
print h1.value # someOtherValue
print h2.value # someOtherValue

Any idea?

Yes : post the relevant code - or at least the minimal code that reproduces the unexpected behaviour.

There are quite a couple gotchas regarding class-vs-instance-attributes and default-params, but none of them matches what you have here - at least if 'value' is an attribute set on 'self' from within the initializer. So either the above snippet is made up and you're in fact having this problem with mutable attributes (like 'value' is a list and you're appending to it) or there's something else in your code.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to