__getitem__() in python2.2

Uwe Schmitt uwe.schmitt at procoders.net
Fri Sep 27 10:46:10 EDT 2002


Hi,

in Python 2.1 one could define

   class X:
       def __getitem__(self, par): print par

and

   a=X()
   a[1,2,3]

resulted in

   (1,2,3)

If I change to newstyle classes, __getitem__ does not accept
tuples anymore. Is there a good reason for this behaviour ?
Can i simmulate the v2.1 functionality ?? It was quite usefull
to access multidimensional matrices...

Greetings, Uwe.


-- 
Uwe Schmitt                    Computer science is no more about Computers,
dr.schmitt at procoders.net       than astronomy is about telescopes. (Dijkstra)
http://www.procoders.net           



More information about the Python-list mailing list