Why Python does *SLICING* the way it does??

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Fri Apr 22 09:46:11 EDT 2005


Reinhold Birkenfeld wrote:

> Other possibility, probably faster when almost all keys in the range are in
> the dictionary:
> 
> class sdict(dict):
>     def __getitem__(self, index):
>         if isinstance(index, slice):
>             d = {}
>             for key in xrange(slice.start, slice.stop, slice.step):

Hm. I wonder whether (x)range could be made accepting a slice as single argument...

Reinhold



More information about the Python-list mailing list