In this snippet:
d = {'x': 1}
value = d.get('x', bigscaryfunctio n())
the bigscaryfunctio n is always called, even though 'x' is a valid key.
Is there a "short-circuit" version of get that doesn't evaluate the
second argument if the first is a valid key? For now I'll code around
it, but this behavior surprised me a bit...
Dave
d = {'x': 1}
value = d.get('x', bigscaryfunctio n())
the bigscaryfunctio n is always called, even though 'x' is a valid key.
Is there a "short-circuit" version of get that doesn't evaluate the
second argument if the first is a valid key? For now I'll code around
it, but this behavior surprised me a bit...
Dave
Comment