curious asymmetry in range limiting

Robin Becker robin at reportlab.com
Tue Mar 20 10:21:02 EDT 2018


I don't know how I never came across this before, but there's a curious asymmetry in the way ranges are limited

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> s = '0123456789'
 >>> print(repr(s[-5:5]))
''
 >>> print(repr(s[5:15]))
'56789'
 >>>

why is the underflow start index treated so differently from the limit index overflow? I suppose there must be some reason, but it 
eludes me.
-- 
Robin Becker




More information about the Python-list mailing list