dunder-docs (was Python is DOOMED! Again!)

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Feb 3 16:39:54 EST 2015


Steven D'Aprano wrote:
> If some methods can be defined outside of the body of a class, then being
> defined inside the body of a class does not define a method.

Nobody's disputing that. The business about super() is
just a possible reason for the glossary to define the
word 'method' in a more restricted way -- because it
simplifies the wording of *other* parts of the docs
that talk about super().

Another thing to consider is that while tricks like
manually inserting __class__ into a function may work
today with CPython, they might not work in future versions
or other implementations. So there are good reasons for
the docs to be conservative about what they promise.

Also, with Python being so dynamic, just about *anything*
you can say about its usual behaviour can be circumvented
with enough hackery. If the docs were to pedantically
take all of those possibilities into account at every
turn, they would be so dense and impenetrable as to
be nearly useless to anyone other than language lawyers.

All this started when I pointed out that *if* you take
the glossary definition of the term 'method' at its
word, then what the docs say about the __dir__ method
won't lead you to think that attaching it to an instance
would work. That's true regardless of whether you think
the glossary definition is too restrictive or not.

I wouldn't have thought that this obvservation would
be so controversial. But maybe I'm wrong, and Python
really is doomed -- to death by language lawyering!-)

-- 
Greg



More information about the Python-list mailing list