Forgetting "()" when calling methods

Terry Reedy tjreedy at udel.edu
Sun Apr 27 01:52:30 EDT 2003


"Erik Max Francis" <max at alcyone.com> wrote in message
news:3EAB6A14.707AD826 at alcyone.com...
> 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(...)

or
print f and f() or 'cannot do that' # assumes boo(f()) always True

I consider it a feature that all objects have truth value (except for
perversely written user classes), so that conditional expressions and
statements always work without exception.

TJR






More information about the Python-list mailing list