enhancing slicing

Markus Schaber markus at schabi.de
Sun Aug 26 18:27:54 EDT 2001


gbreed at cix.compulink.co.uk <gbreed at cix.compulink.co.uk> schrub:

>> My proposal is to introduce a new operator, for instance # (count):
>> v[5 # 2]
>> Extract 2 elements starting at 5: [ v[5], v[6] ]. Equivalent to
>> v[5:5+2]
> 
> I don't think # is right, because it's already used for comments.  But
> perhaps :][: would do the trick.  So it'd be v[5 :][: 2].  It's more
> complex, but looks nice.  And doesn't introduce any new punctuation
> into
> the language.  Shall I start on the PEP?

PEP?

As far as I see it, this already works using python 1.5.2:

>>> list = [1,2,3,4,5,6,7,8,9,0]
>>> list[5:]
[6, 7, 8, 9, 0]
>>> list[5:][:2]
[6, 7]

markus

-- 
1) Customers cause problems.
2) Marketing is trying to create more customers.
Therefore:
3) Marketing is evil.  (Grand Edwards in comp.lang.python)



More information about the Python-list mailing list