Forgetting "()" when calling methods

Andrew Bennetts andrew-pythonlist at puzzling.org
Sun Apr 27 04:06:22 EDT 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 erro.py file:
> 
> import sys
> sys.exit
> 
> and now run:
> 
> [alex at lancelot booksa]$ pychecker erro.py
> Processing erro...
> 
> Warnings...
> 
> erro.py:2: 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 erro1.py:

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 :)

-Andrew.






More information about the Python-list mailing list