cfgauss wrote:
> I am having a strange problem with classes. I'm fairly sure the
> problem is with classes, anyway, because when I re-write the program
> without them, it works like I'd expect it to.
>
> When I run this program, at first, L[0].z[1] is 0, because z=[0,0].
> But after I run that loop to assign different values to L[1].z[0] and
> L[1].z[1], somehow the value of L[0].z[1] has changed to 1. I have no
> idea why this is happening, can anyone help me?
>
> class Stuff:
> z=[0,0]
This is a class attribute (shared by all instances of Stuff), not an
instance attribute.
To define instance attribute, the syntax is:
class Stuff(object):
def __init__(self):
self.z = [0, 0]
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
--
http://mail.python.org/mailman/listinfo/python-list