[Python-Dev] python3k change to slicing

Guido van Rossum guido at python.org
Thu Apr 19 19:40:41 CEST 2007

[+python-3000; followups please remove python-dev]


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.

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,


On 4/19/07, Neal Becker <ndbecker2 at gmail.com> wrote:
> There is one thing I'd like to see changed in a future python.  I always
> found it surprising, that
> >>> x = [1,2,3,4,5]
> >>> x[1:10]
> [2, 3, 4, 5]
> is not an error.  This is perhaps the only case (but a fundamental one!)
> where an error is silently ignored.
> I really can't think of a good justification for it.  If I really meant
> x[1:]
> I would have said so.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list