On Sun, May 20, 2012 at 5:44 AM, pete McEvoy wrote:
> I am confused by some of the dictionary setdefault behaviour, I think
> I am probably missing the obvious here.
>
> def someOtherFunct():
> print "in someOtherFunct"
> return 42
>
> x = myDict.setdefault(1, someOtherFunct()) # <
Ah - I have checked some previous posts (sorry, should
have done this first) and I now can see that the
lazy style evaluation approach would not be good.
I can see the reasons it behaves this way.
many thanks anyway.
--
http://mail.python.org/mailman/listinfo/python-list
On 19/05/2012 20:44, pete McEvoy wrote:
I am confused by some of the dictionary setdefault behaviour, I think
I am probably missing the obvious here.
def someOtherFunct():
print "in someOtherFunct"
return 42
def someFunct():
myDict = {1: 2}
if myDict.has_key(1):
pri
I am confused by some of the dictionary setdefault behaviour, I think
I am probably missing the obvious here.
def someOtherFunct():
print "in someOtherFunct"
return 42
def someFunct():
myDict = {1: 2}
if myDict.has_key(1):
print "myDict has key 1"
x = myDict.setdefault