How to store the reference of a dictionary element ?

Mike Meyer mwm at mired.org
Fri Dec 20 01:47:30 EST 2002


Mike Meyer <mwm at mired.org> writes:

> Ok, now the solution is easy. Don't use lists. Use your own class that
> look like lists:
> 
> class MenuList(list):
>    def __setitem__(index, item): my[index][0] = item
>    def __getitem__(index): return my[index][0]

Sigh. Of course that should be:

class MenuList(list():
   def __setitem__(my, index, item): my[index][0] = item
   def __getitem__(my, index): return my[index][0]


        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list