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/000582.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 secondM.-A. Lemburg mal@lemburg.com
Fri, 23 Jul 1999 13:07:22 +0200
Christian Tismer wrote:
> 
> "M.-A. Lemburg" wrote:
> ...
> > Also, has anybody considered writing list.pop(..,default) this way:
> >
> > if list:
> >         obj = list.pop()
> > else:
> >         obj = default
> >
> > No exceptions, no changes, fast as hell :-)
> 
> Yes, that's the best way to go, I think.
> But wasn't the primary question directed on
> an atomic function which is thread-safe?
> I'm not sure, this thread has grown too fast :-)

I think that was what Jim had in mind in the first place.
Hmm, so maybe we're not after lists after all: maybe what
we need is access to the global interpreter lock in Python,
so that we can write:

sys.lock.acquire()
if list:
        obj = list.pop()
else:
        obj = default
sys.lock.release()

Or maybe we need some general lock in the thread module for these
purposes... don't know. It's been some time since I used
threads.

-- 
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