short path evaluation, why is f() called here: dict(a=1).get('a', f())
Chris Mellon
arkanes at gmail.com
Mon Jan 14 13:49:57 EST 2008
On Jan 14, 2008 12:39 PM, aspineux <aspineux at gmail.com> wrote:
>
> This append in both case
>
> dict(a=1).get('a', f())
> dict(a=1).setdefault('a', f())
>
> This should be nice if f() was called only if required.
>
Think about the change to Python semantics that would be required for
this to be true, and then use collections.defaultdict instead.
More information about the Python-list
mailing list