Forgetting "()" when calling methods

Alex Martelli aleax at aleax.it
Sun Apr 27 03:54:28 EDT 2003


Erik Max Francis wrote:

> Jeremy Fincher wrote:
> 
>> Perhaps the answer is to remove the __nonzero__ method on
>> functions/methods.  Logically, what purpose does it serve?
> 
> # f holds a callable object or None
> if f:
> f(...)
> 

I think "if f is None:" and even more "if callable(f):" are
better ways to express this test -- explicit is better than
implicit.  However, if this (inferior) expression is indeed
widespread, then we can't break it until Python 3000 (well,
we COULD start giving warnings about it, etc, etc, but it's
unlikely that this can happen).


Alex





More information about the Python-list mailing list