On 2011-12-13, Andrea Crotti <andrea.crott...@gmail.com> wrote: > Now somewhere else I had > > if func_bool: > # do something > > I could not quite understand why it was always true, until I finally > noticed that the () were missing. Is there some tool to avoid these > stupid mistakes? (pylint doesn't warn me on that) I don't think I > will ever (or almost) have to use a function as a boolean, instead of > its return value...
FWIW, I have do use the truth value of a function (rather than it's return value) when writing code that uses callbacks: def foo(callback=None): # do some stuff if callback: callback() # do some more stuff It probably would be better to use "if callback is not None:", but I find I usually skip "is not None". -- Grant Edwards grant.b.edwards Yow! Will it improve my at CASH FLOW? gmail.com -- http://mail.python.org/mailman/listinfo/python-list