curious about slice behaviour
Stephan Diehl
stephan.diehl at gmx.net
Mon Sep 5 13:06:42 EDT 2005
I just found out by accident, that slice indices can be larger than
the length of the object. For example
>>> 'test'[:50]
'test'
>>> 'test'[40:50]
''
I'd rather expected to be confronted with an IndexError.
(This is actually described in
http://docs.python.org/lib/typesseq.html, so my expectation was wrong :))
Does anybody know, why this is preferred to just raising an error?
More information about the Python-list
mailing list