[Python-3000] PEP 3124 - Overloading, Generic Functions, Interfaces, etc.

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 3 08:27:55 CEST 2007

Phillip J. Eby wrote:

> "After you start a transaction on a database, make 
> sure you turn its logging up all the way."
> Please explain how you would improve one the clarity of that sentence 
> *without* using the word "after" or any synonyms thereof.

I don't object to using the word "after" in the docstring
if it helps. Although in this case the intent could be
described as "Ensure that all transactions are performed
with logging turned up all the way." Whether this is
done before or after starting the transaction doesn't
seem particularly important.

If it *is* important for some reason, that fact should
be mentioned in the docstring. The mere presence of an
@after decorator doesn't indicate whether it's important.
And if it's mentioned in the docstring, there's no need to
announce it again in the decorator.

> ISTM that your argument is like saying there's no need for C
 > with all its fancy function parameter names

Parameter names help to document the interface of a
function, which is something you need to know when you're
calling it. You don't need to know the position of a
next-method call to use a generic function.

I don't doubt that things like @before and @after are
handy. But being handy isn't enough for something to
get into the Python core. Python has come a long way
by providing a few very general mechanisms that can
be used in flexible ways. It tends not to go in for
gimmicks whose only benefit is to save a line or two
of code here and there. I think the same philosophy
should be applied to generic functions if we are to
get them.


More information about the Python-3000 mailing list