Class v. Instance variables in Python
Zane Selvans
zane at ideotrope.org
Mon Nov 10 16:44:21 EST 2008
I have defined a class called Lineament, which has no class variables
- only instance variables, defined and set within __init__(), and
later potentially modified by other class methods.
However, one (and only one) of these instance variables is behaving
mysteriously like a class variable: all instances of the class are
sharing a single copy of the variable, located at the same place in
memory.
Is there a common mistake that can result in this behavior, that
doesn't involve using class variables - I really have absolutely
nothing defined in the class except for methods. The problem shows up
regardless of how I name the instance variables (i.e. using name
mangling __names or not). The problematic variable consists of a list
of objects of type Lineament (the same object class as the one that's
giving me problems).
Thanks for any suggestions... sorry I didn't include example code. I
haven't been able to boil it down to a minimal example yet.
Zane
--
Zane Selvans
Amateur Earthling
zane at ideotrope.org
303/815-6866
http://zaneselvans.org
PGP Key: 55E0815F
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20081110/fb9b7bff/attachment.html>
More information about the Python-list
mailing list