Re: slice last 4 items from a list

2007-10-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, John Machin wrote: > On Oct 2, 6:27 am, brad <[EMAIL PROTECTED]> wrote: >> Is this the correct way to slice the last 4 items from a list? >> >> x = [1,2,3,4,5,6,7,8,9] >> print x[-4:] >> >> It works, but is it Pythonic? > > It's Pythonic. It's also unambiguous, unl

Re: slice last 4 items from a list

2007-10-01 Thread James Matthews
Very pythoninc! On 10/1/07, John Machin <[EMAIL PROTECTED]> wrote: > > On Oct 2, 6:27 am, brad <[EMAIL PROTECTED]> wrote: > > Is this the correct way to slice the last 4 items from a list? > > > > x = [1,2,3,4,5,6,7,8,9] > > print x[-4:] > > > > It works, but is it Pythonic? > > It's Pythonic. It'

Re: slice last 4 items from a list

2007-10-01 Thread John Machin
On Oct 2, 6:27 am, brad <[EMAIL PROTECTED]> wrote: > Is this the correct way to slice the last 4 items from a list? > > x = [1,2,3,4,5,6,7,8,9] > print x[-4:] > > It works, but is it Pythonic? It's Pythonic. It's also unambiguous, unlike your specification, which could be interpreted as 'chop off

Re: slice last 4 items from a list

2007-10-01 Thread Bruno Desthuilliers
brad a écrit : > Is this the correct way to slice the last 4 items from a list? > > x = [1,2,3,4,5,6,7,8,9] > print x[-4:] > > It works, but is it Pythonic? Is there a more obvious (for a pythonic definition of 'obvious') way to do it ? If no, then it's pythonic... Now FWIW, I usually use 'esr