"Ben" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> class record:
>         my_list =[]
>         mops=[]
>
>         def __init__(self,mops):
>                 self.mops=mops

Similar to the example I gave, the lists my_list and mops shown above are
executed just once: when your class definition is first parsed.
The statement:

def __init__(self,mops):

is also executed just once, and the value for mops at that time is the value
assigned to object attributes during object construction - a reference to
record.mops, in your case.  So, there are really only two lists here, class
attributes record.my_list and record.mops.  Each of your constructed objects
is assigned a reference to record.mops.  They all share that list.  If you
want a record object to have it's own list, give it a new, empty one and
then populate it appropriately.




-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to