[Python-Dev] python3k change to slicing

2007-04-19 Thread Neal Becker
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@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python3k change to slicing

2007-04-19 Thread Guido van Rossum
[+python-3000; followups please remove python-dev]

-1

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,
len(s))].

--Guido

On 4/19/07, Neal Becker [EMAIL PROTECTED] 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@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/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] python3k change to slicing

2007-04-19 Thread Jon Ribbens
Guido van Rossum [EMAIL PROTECTED] wrote:
 -1

Me too.

 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,
 len(s))].

... 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.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com