Slices... what are they good for?

John Lehmann johnl at axis.com.au
Wed Mar 20 19:03:51 EST 2002


I had forgotted slices existed, until I was making an object that I
was pretending was a tuple.

I was shocked to find that this didn't work:

>>> l = ['a', 'b', 'c']
>>> l[1:2]
'b'
>>> l[ slice(1,2) ]
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
TypeError: sequence index must be integer

--
| John J. Lehmann, jlehmann(@)cgi-australia.com
+ Chicago Bulls star has filed papers seeking to annul his 9-day-old 
+ marriage to the former Playboy and Baywatch babe, saying he was of 
+ "unsound mind" when the wedding took place.



More information about the Python-list mailing list