Re: [Python-Dev] __getitem__ in user defined classes

Oct. 21, 2002
10:06 a.m.
"Raymond Hettinger" <python@rcn.com> writes:
You can spell that if isinstance(index, slice): return [x**2 for x in range(*index.indices(11))] and, as a bonus, it'll work more often <wink> (consider "SquaresToTen()[7::-2]", for example).
However to make omitted slice places work, you need to pass in the length of the sequence, so I don't think this can fly. Cheers, M. -- We've had a lot of problems going from glibc 2.0 to glibc 2.1. People claim binary compatibility. Except for functions they don't like. -- Peter Van Eynde, comp.lang.lisp
8184
Age (days ago)
8184
Last active (days ago)
0 comments
1 participants
participants (1)
-
Michael Hudson