enhancing slicing
gbreed at cix.compulink.co.uk
gbreed at cix.compulink.co.uk
Thu Aug 23 09:46:33 EDT 2001
In article <9m2sij$1f8s$1 at ID-102451.news.dfncis.de>, juanv at posta.unizar.es
(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]
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?
> v[5 # -2]
> Extract 2 elements ending at (but not including the) 5: [ v[3], v[4] ].
> Equivalent to v[5-2:5]
I'm not sure the the :][: operator would be appropriate here, but maybe
the variation v[:5 ][ -2:] could be made to work.
> I think that this little syntactic sugar allows programs more compact
> and
> readable. Also, I had less "start and end point paranoias". I suppose
> that
> the implementation is easy and the current programs are not affected at
> all.
Would my suggestions be much harder to implement?
Graham
More information about the Python-list
mailing list