A RetroSearch Logo

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

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/1999-July/000557.html below:

[Python-Dev] I'd like list.pop to accept an optional second

[Python-Dev] I'd like list.pop to accept an optional second [Python-Dev] I'd like list.pop to accept an optional secondGordon McMillan gmcm@hypernet.com
Thu, 22 Jul 1999 11:33:06 -0500
Jim Fulton wrote:

> Gordon McMillan wrote:
> > 
> > Then how do I get the old behavior? 
> 
> Just pass 0 or 1 argument.
> 
> >(I've been known to do odd
> > things - like change behavior based on the number of args - in
> > extension modules, but this ain't an extension).
> 
> It *is* a built-in method.  It will be handled just like
> dictionaries handle the second argument to get.

d.get(nonexistantkey) does not throw an exception, it returns None.

If list.pop() does not throw an exception when list is empty, it's 
new behavior.

Which are you asking for:
 breaking code that expects IndexError
Violating Pythonic expectations by, in effect, creating 2 methods
 list.pop(void)
 list.pop(default_return)

- Gordon



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