accessing front of a list
Hans Nowak
wurmy at earthlink.net
Tue Nov 26 20:10:33 EST 2002
Simon Bunker wrote:
> This is probably a fairly newbie question - and also because I am
> coming from a Perl background. I was wondering if there is a Python
> equivilant to Perls shift operator?
>
> There seem to be many ways of getting access to the end of an array -
> pop() append() etc but I couldn't find anyting to shift off the front like
> when
> reading in argv.
You probably want pop(0):
>>> a = range(5)
>>> x = a.pop(0)
>>> x
0
>>> a
[1, 2, 3, 4]
...but destructive processing of lists this way is relatively rare, IMHO.
> This may be becausde I was only learning from the online tutorial/docs which
> I have't finished going through. Are there any books worth buying -
> particularly
> O'Reilley ones? I have seen Learning Python but don't know if this will
> cover much more
> (although the Perl Llama book isalways useful for Perl), the Programming
> Python
> and Python Cookbook and the Standalrd Library book. It would be nice if
> there was a
> "in a Nutshell" one.
People are working on it...
--
Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA=='))
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
Kaa:: http://www.awaretek.com/nowak/kaa.html
More information about the Python-list
mailing list