Proposed PEP: New style indexing, was Re: Bug in slice type
fakeaddress at nowhere.org
Wed Aug 24 15:28:16 CEST 2005
Paul Rubin wrote:
> Bryan Olson writes:
>> seq[3 : -4]
>> seq[3 ; $ - 4]
I think you're wrong about the "+1". I defined '$' to stand for
the length of the sequence (not the address of the last
>>When square-brackets appear within other square-brackets, the
>>inner-most bracket-pair determines which sequence '$' describes.
>>(Perhaps '$$' should be the length of the next containing
>>bracket pair, and '$$$' the next-out and...?)
> Not sure. $1, $2, etc. might be better, or $<tag> like in regexps, etc.
> Hmm, tuples are hashable and are already valid indices to mapping
> objects like dictionaries. Having slices means an object can
> implement both the mapping and sequence interfaces. Whether that's
> worth caring about, I don't know.
Yeah, I thought that alternative might break peoples code, and
it turns out it does.
More information about the Python-list