Some "pythonic" suggestions for Python

Duncan Booth duncan.booth at invalid.invalid
Fri Nov 9 04:17:18 EST 2007


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:

> Besides, if you want this behaviour, you can add it yourself:
> 
> class mylist(list):
>     # Untested!
>     def __getitem__(self, index):
>         if type(index) is list:
>              return [self[i] for i in index]
>         return super(mylist, self).__getitem__(index)
> 
> list = mylist

It works very nicely, just don't try passing it a recursive list.

 :)



More information about the Python-list mailing list