Forgetting "()" when calling methods
Andrew Bennetts
andrew-pythonlist at puzzling.org
Sun Apr 27 04:36:16 EDT 2003
On Sun, Apr 27, 2003 at 07:54:28AM +0000, Alex Martelli wrote:
> 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
Taken to extremes, "explicit is better than implicit" suggests we should be
using a statically typed language.... ;)
Fortunately, The Zen of Python has plenty of mildly contradictory
statements, which helps in defending one's viewpoint :)
-Andrew.
More information about the Python-list
mailing list