Forgetting "()" when calling methods

Terry Reedy tjreedy at udel.edu
Sun Apr 27 21:59:20 EDT 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:7ULqa.9804$3M4.264757 at news1.tin.it...
> Terry Reedy wrote:
> > 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.
>
> It's a feature, just like it WAS a feature that you USED TO be able
> to always test "if a>b:" without exception.

And I am not convinced that removing that invariant was entirely a
good idea.  I noticed on PyDev a couple of months ago that even Guide
has some sympathy for that view and the idea of adding a before()
method or something that would restore it.

Having some things like this that are/were true without exception (in
both the English and Python meanings of the word) are part of what
attracted me to Python.  They certainly made learning the language
easier for me (and other, I would think -- and I thought you also
cared about that ;-).

At one time, it was easy for anyone to get 100% on a quiz like 'how
many of the following lists can Python sort?".  Now, even some
experienced users, might miss the correct answer for the following
pair (0, 1, or 2?):

[1, 1j].sort()
['1', 1j].sort()

(For anyone who is not sure, make a guess and then cut&paste to fine
out.)

One bad turn does not deserve another.

Terry J. Reedy






More information about the Python-list mailing list