slices: foo[i:j:k] => TypeError
Roman Neuhauser
neuhauser at mail.cz
Fri Apr 26 17:36:54 EDT 2002
Hi there,
I'm playing with Python, and found something that seems to contradict
the description in Language Reference:
roman at roman ~ > python
Python 2.1.1 (#1, Oct 12 2001, 20:13:31)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> foo = list ('abcdefghijkl')
>>> foo
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']
>>> foo[0]
'a'
>>> foo[0:6]
['a', 'b', 'c', 'd', 'e', 'f']
>>> foo[0:6:2]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
>>>
What's up? Is that a bug, or am I dumb?
--
FreeBSD 4.4-STABLE
11:31PM up 11 days, 12:43, 14 users, load averages: 0.06, 0.12, 0.10
More information about the Python-list
mailing list