enhancing slicing

Skip Montanaro skip at pobox.com
Thu Aug 23 10:27:05 EDT 2001


    graham> In article <9m2sij$1f8s$1 at ID-102451.news.dfncis.de>, juanv at posta.unizar.es 
    graham> (Juan Valiño) wrote:

    >> 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]

    graham> I don't think # is right, because it's already used for
    graham> comments.  But perhaps :][: would do the trick.  So it'd be v[5
    graham> :][: 2].  It's more complex, but looks nice.  And doesn't
    graham> introduce any new punctuation into the language.  Shall I start
    graham> on the PEP?

Would never fly.  There is already semantic meaning associated with v[5:]
and v[5:][:2].  Adding spaces and making ":][:" an operator would just break
things.  What would you call it?  "+" is the "addition operator".  

    graham> Would my suggestions be much harder to implement?

Somewhat harder than you imagine, yes. ;-)

-- 
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/




More information about the Python-list mailing list