Python + strange == cool
Phil Frost
indigo at bitglue.com
Tue Sep 28 19:30:35 EDT 2004
More information about the Python-list mailing list
Tue Sep 28 19:30:35 EDT 2004
- Previous message (by thread): Python + strange == cool
- Next message (by thread): Python + strange == cool
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The second number in the slice is the index of the last element to be included, exclusive. It is not an offset from the first index. Adding the "+" does nothing; that just means "positive". As the laws of mathematics dictate, "+n = n"; the unary + is just for symmetry with the unary '-'. On Tue, Sep 28, 2004 at 04:21:12PM -0700, Maboroshi wrote: > All fine and good <below> > > >>> x = ["list1", "list2", "list3", 4, 5, 6, 7] > >>> x[1:-1] > ['list2', 'list3', 4, 5, 6] # All good here > > this struck me as weird I had an idea to mess around with lists <below> > > >>> x[1:+1] > [] > > now when I do this > >>> x[1:+2] > ['list2'] > > Does this puzzle anyone else > > of course I am a total novice so I have no idea what I am doing here if > anyone has any ideas please reply
- Previous message (by thread): Python + strange == cool
- Next message (by thread): Python + strange == cool
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list