Specify start and length, beside start and end, in slices
Noam Raphael
noamr at correctme.users.sourcephorge.net
Fri May 21 11:22:31 EDT 2004
Grant Edwards wrote:
> On 2004-05-21, Noam Raphael <noamr at correctme.users.sourcephorge.net> wrote:
>
>
>>Many times I find myself asking for a slice of a specific length, and
>>writing something like l[12345:12345+10].
>
>
> [...]
>
>
>>Wouldn't it be nice if the Python grammar had supported this frequent
>>use? My idea is that the expression above might be expressed as
>>l[12345:>10].
>
>
> It's a bit less efficient, but you can currently spell that as
>
> l[12345:][:10]
>
That is true, but if the list is long, it's *much* less efficient.
Thanks for your comment,
Noam
More information about the Python-list
mailing list