A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-March/002646.html below:

[Python-Dev] list.shift()

[Python-Dev] list.shift()Guido van Rossum gvanrossum@beopen.com
Fri, 17 Mar 2000 17:00:18 -0500
Ka-Ping Yee wrote:
> 
> Has list.shift() been proposed?
> 
>     # pretend lists are implemented in Python and 'self' is a list
>     def shift(self):
>         item = self[0]
>         del self[:1]
>         return item
> 
> This would make queues read nicely... use "append" and "pop" for
> a stack, "append" and "shift" for a queue.
> 
> (This is while on the thought-train of "making built-in types do
> more, rather than introducing more special types", as you'll see
> in my next message.)

You can do this using list.pop(0).  I don't think the name "shift" is very
intuitive (smells of sh and Perl :-).  Do we need a new function?

--Guido



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4