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/000559.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 secondM.-A. Lemburg mal@lemburg.com
Thu, 22 Jul 1999 19:27:53 +0200
Jim Fulton 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.

Wouldn't a generic builtin for these kinds of things be
better, e.g. a function returning a default value in case
an exception occurs... something like:

tryexcept(list.pop(), IndexError, default)

which returns default in case an IndexError occurs. Don't
think this would be much faster that the explicit try:...except:
though...

-- 
Marc-Andre Lemburg
______________________________________________________________________
Y2000:                                                   162 days left
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



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