Is there a short-circuiting dictionary "get" method?

Terry Reedy tjreedy at udel.edu
Fri Mar 11 01:19:44 EST 2005


"Skip Montanaro" <skip at pobox.com> wrote in message 
news:16943.18475.568383.983546 at montanaro.dyndns.org...
>    value = d.get('x') or bsf()
>
> Of course, this bsf() will get called if d['x'] evaluates to false, not 
> just
> None,

value = (d.get('x') is not None) or bsf() #??

tjr






More information about the Python-list mailing list