Ummm...that doesn't do what I asked.

pop is a linguistic idiom for

(val, mylist) = (mylist[-1], mylist[0:-1])

shift is the standard idiom for 

(val, mylist) = (mylist[0], mylist[1:])

but Python doesn't appear to offer this.

Jeff

-----Original Message-----
From: Kent Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 03, 2005 9:15 AM
Cc: tutor@python.org
Subject: Re: [Tutor] Deleting an entry from a dictionary


Smith, Jeff wrote:
> Speaking of which, I note that there is a pop for lists but no shift.
> Is there a Python idiom for this or is it just
>     val = mylist.shift() =>    (val, mylist) = (mylist[0], mylist[1:])
> which seems a little clumsy.

val = mylist.pop(0)

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to