Forgetting "()" when calling methods

Andrew Bennetts andrew-pythonlist at
Sun Apr 27 10:06:22 CEST 2003

On Sun, Apr 27, 2003 at 07:38:47AM +0000, Alex Martelli wrote:
> Andrew Bennetts wrote:
>    ...
> > For that matter, removing __nonzero__ from functions still doesn't help
> > this case:
> > 
> >     sys.exit
> > 
> > So it's of pretty minimal benefit.
> Not really.  Write the following file:
> import sys
> sys.exit
> and now run:
> [alex at lancelot booksa]$ pychecker
> Processing erro...
> Warnings...
> Statement appears to have no effect
> [alex at lancelot booksa]$
> See?  PyChecker CAN and DOES warn about "this case"!  But OF COURSE
> it can't help with the following

Sure, but I said: "removing __nonzero__ from functions still doesn't help
this case".  You can catch that today, with PyChecker, as you've demonstrated.
And that's great -- that's helped me perhaps once or twice, iirc, back when
I used to do some VB in between Python work, and occasionally got confused
for a moment.

It's still not a justification for breaking __nonzero__ on functions.  There
are plenty of cases where "if func:" is perfectly valid, and no amount of
"SINERGY" is going to convince me that making that fail (either in PyChecker
or at runtime) is a good idea :)


More information about the Python-list mailing list