Forgetting "()" when calling methods

Alex Martelli aleax at aleax.it
Sun Apr 27 06:48:39 EDT 2003


Andrew Bennetts wrote:

> On Sun, Apr 27, 2003 at 07:38:47AM +0000, Alex Martelli wrote:
   ...
>> 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

I.e., it doesn't help with a case that doesn't really need help -- is THAT
the "point" you thought it was worth a post to make (and DIDN'T mention!)?

There are a zillion cases where no "help" is particularly needed nor
warranted.  The fact that any proposed change "doesn't help" with any
subset of the cases that don't particularly need help is so clearly
irrelevant to any assessment of that proposed change that I _still_
don't see why ever one would want to start enumerating such cases.


> It's still not a justification for breaking __nonzero__ on functions. 

Would it damage you if that __nonzero__ raised a warning that is
suppressed by default, but can easily be (selectively) enabled?

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

I apologize for the misspelling, but it doesn't affect my argument.

The Romans said "experientia docet stultos" -- implying that some
people, presumably "the wise", can learn from the experience of
OTHERS, while others, "the foolish", only learn from their own.  I
find that few enough people learn even from their own experiences, 
that I consider this proverb to be wishful thinking.  But still, it
does seem to apply to the case in point.

You mentioned that you have no extensive experience teaching newbies,
particularly ones that come from the many languages where trailing
empty parentheses are not necessary to call an argument-less function,
such as Pascal and its descendants, as well as Visual Basic.  Yet it
is exactly to help such newbies that I'm considering making __nonzero__
raise an optional warning for function and method objects -- help them,
together with PyChecker for the diagnosis of other cases, get info
ASAP about the fact that once again they've forgotten a trailing '()',
rather than having to deduce it from subtle errors arising later and
quite possibly in quite separate points of their code.

If you have no experience with such teaching, nor any empathy for the
needs of support of such newbies, then my posts surely can't give it.
Just about the only thing I can do, is wish and hope that you will
find yourself thrust into such a teaching position, have to live with
the resulting frustration, and hopefully reflect that it could in
some part have been diminished if these warnings had been added.

They won't be, I think -- because of what was posted on this thread
by exactly one of the people I think such an addition would help.  He
argued, instead, that there will be no learning, ever, of the fact that
you need trailing parentheses to call callables without arguments; AND 
that the diagnosis should be performed in PyChecker (i.e. by static
checking), which is simply unfeasible -- implying that it would not help 
to have instead the optional early, precise warning that WOULD be feasible.

I think he's dead wrong on both accounts, but my disagreement in this
case has to be of a very different order from the one I have with you: I
can hardly claim I have MORE experience than he does at BEING a newbie,
after all.  In other words, my conviction that he's dead wrong is based
on arrogance -- on believing that I know what's best for HIM, better
than he does himself.  Sometimes (e.g. to act as a teacher) one does
need some touch of that kind of arrogance -- to do what one's deeply
convinced is best for the student, rather than what the student very
explicitly asks for -- but nevertheless I detest acting on such a basis.

Arrogant people, and teachers in particular, do much more harm than good
in this world.  I cannot erase my own arrogance just by wishing it gone,
but I can, at least, avoid acting on it when I have an option -- and in
this case, I do, and the "creative non-action" choice of doing nothing
at all on this subject thereby becomes attractive.


Alex





More information about the Python-list mailing list