A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/319673.html below:

curious about slice behaviour

curious about slice behaviour curious about slice behaviourStephan 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4