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/1999-July/000560.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 secondGordon McMillan gmcm@hypernet.com
Thu, 22 Jul 1999 11:54:58 -0500
Jim Fulton wrote:
>
> Gordon McMillan wrote:
...
> > Violating Pythonic expectations by, in effect, creating 2 methods
> >  list.pop(void)
> >  list.pop(default_return)
> 
> Yes, except that I disagree that this is non-pythonic.
> 

I'll leave the final determination to Mr. Python, but I disagree. 
Offhand I can't think of a built-in that can't be expressed in normal 
Python notation, where "optional" args are really defaulted args.

Which would lead us to either a new list method, or redefining pop:

 def pop(usedefault=0, default=None)

and making you use 2 args.

But maybe I've missed a precedent because I'm so used to it. (Hmm, I 
guess string.split is a sort-of precedent, because the first default 
arg behaves differently than anything you could pass in).

- 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