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

Jim Fulton jim@digicool.com
Fri, 23 Jul 1999 07:58:23 -0400


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?

Right. And the above code doesn't solve this
problem. Tim's code *does* solve the problem.
It's the code we were using.  It is a bit 
verbose though.


> I'm not sure, this thread has grown too fast :-)

Don't they all?

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.org    

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.