Question: lists in classes

Jeff Turner jturner at ug.cs.su.oz.au
Mon Aug 30 01:34:59 EDT 1999


Apologies if this has been answered before...

class foo:
    list=[]

a=foo()
b=foo()
a.list.append(123)
print b.list

I would expect the above code to return "[]", since b has not been
modified since instantiation. However it returns [123].

How would I tell python that I only want to _define_ the class, not
instantiate it?

Thanks,
Jeff







More information about the Python-list mailing list