Specify start and length, beside start and end, in slices

Grant Edwards grante at visi.com
Fri May 21 11:16:03 EDT 2004


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]

-- 
Grant Edwards                   grante             Yow!  We just joined the
                                  at               civil hair patrol!
                               visi.com            



More information about the Python-list mailing list