sharing data in list sub-classes

Sergei Barbarash sgt at outline.ru
Tue Jun 4 08:49:19 EDT 2002


Hello,

Is there a way to share list data in classes that inherit the "list" class?

Example:

,----
| class A(list):
|     <what should I put here?>
| 
| mem = [1,2,3,4,5]
| 
| a1 = A(mem)
| a2 = A(mem)
| 
| a1[0] = 1024
| if a2[0] == 1024:
|     print "Everything's fine"
`----

With obsolete UserList module it works fine, because it stores the data in
self.data variable. Is there a "right" 2.2-ish way to do the same thing?

Thanks,
-- 
Sergei



More information about the Python-list mailing list