18 Feb
2006
18 Feb
'06
5:22 a.m.
Adam Olsen wrote:
Consider these two pieces of code:
if key in d: dosomething(d[key]) else: dosomethingelse()
try: dosomething(d[key]) except KeyError: dosomethingelse()
Before they were the same (assuming dosomething() won't raise KeyError). Now they would behave differently.
I personally think they should continue to do the same thing, i.e. "in" should return True if there is a default; in the current proposal, it should invoke the default factory. But that's beside the point: Where is the real example where this difference would matter? (I'm not asking for a realistic example, I'm asking for a real one) Regards, Martin