Re: setdefault behaviour question

2012-05-19 Thread pete McEvoy
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

setdefault behaviour question

2012-05-19 Thread pete McEvoy
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