weird: "if x" and "if x is not None"

Fortepianissimo fortepianissimo at yahoo.com.tw
Mon May 19 11:36:26 EDT 2003


I don't know what has changed, but the following code used to work
fine now it doesn't:

result=d.get("key")
if result:
  # do something...


the problem seems to be at "if result:" - before when result is not
None, the if block will be executed. Now I have to literally say "if
result is not None:" instead of that line.

My question is, what does the 'standard' say about this? (any non-None
will make an 'if' test succeed?)

Thx in advance.




More information about the Python-list mailing list