negative indices for sequence types
Jacek Generowicz
jacek.generowicz at cern.ch
Wed Sep 17 04:43:13 EDT 2003
More information about the Python-list mailing list
Wed Sep 17 04:43:13 EDT 2003
- Previous message (by thread): negative indices for sequence types
- Next message (by thread): python module for MS SQL Server 7 or 2000?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
danbmil99 at yahoo.com (dan) hypothesizes: > My explanation of the behavior is correct however. list[a] always > equals list[a % len(list)]. A negative number mod N = its absolute > value subtracted from N: Proof by counterexample: Python 2.2.2 (#1, Feb 8 2003, 12:11:31) [GCC 3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> s = '0123' >>> s[-20 % len(s)] '0' >>> s[-20] Traceback (most recent call last): File "<stdin>", line 1, in ? IndexError: string index out of range Your explanation of the behaviour is incorrect. QED.
- Previous message (by thread): negative indices for sequence types
- Next message (by thread): python module for MS SQL Server 7 or 2000?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list