[Python-Dev] python3k change to slicing
jon+python-dev at unequivocal.co.uk
Thu Apr 19 20:03:56 CEST 2007
Guido van Rossum <guido at python.org> wrote:
> While this may be theoretically preferable, I believe that in practice
> changing this would be a major pain for very little gain. I don't
> recall ever finding a bug related to this feature, and I believe it's
> occasionally useful.
I find it quite frequently useful.
> Here's something that would be much more cumbersome with your proposed
> change: suppose I have a string of unknown length and I want to get
> the first three characters, or less if it's not that long. Today I can
> write s[:3]. With your proposal I would have to write s[:min(3,
... and that's exactly the sort of situation I find it useful ;-)
I certainly think it's easier to check that your result is the length
you wanted on the occasions you need to, than it would be to make the
replacement you show above everywhere else.
More information about the Python-Dev