[Python-ideas] Proposal for new-style decorators

Stephen J. Turnbull stephen at xemacs.org
Wed Apr 27 04:44:28 CEST 2011


Christophe Schlick writes:

 >  What I wanted to say is that wraps only does half of the job: it
 >  correctly copies the name and the docstring, but the signature
 >  presented by the help function is still test(*args, **keys), while it
 >  should actually be test(first=0, last=0) according to the undecorated
 >  function.

But that's a lie; the undecorated function is *not* what *my* code
calls.  I would be very confused if I committed a syntax error
according to the help, but the compiler let it go silently.  In your
approach, this doesn't get caught until the erroneous call is actually
made, which might be after the code is put into production.  Or it may
not get caught at all, depending on whether the
decorater-decorater-decorated function checks arguments or simply
swallows unneeded arguments.

In the standard approach, I see "test(*args, **keys)" and go "!@#$%
Name your !@#$% arguments, for heaven's sake!" and go read the code
(the first time), or "oh, it's decorated, gotta read the code, I guess
... mmrmfrmblgrr" (with experience).  But the help's less-than-
informative signature tells me I need to review carefully, whereas in
your approach I would tend to leave it up to the compiler to some
extent.



More information about the Python-ideas mailing list