[Python-ideas] Multiple arguments for decorators

Brendan Barnwell brenbarn at brenbarn.net
Tue Dec 1 14:09:49 EST 2015


On 2015-12-01 08:22, Guido van Rossum wrote:
> On the other hand, if we're willing to put up with some ugliness in the
> *implementation*, the *notation* can be fairly clean (and avoid the
> creation of a class object):

	I like this way of doing it.  It's more fluid than the other proposed 
solutions and is instantly understandable.  I don't even think the 
implementation is ugly; it's just a bit complex.  But I think using 
complex machinery on the back end to support a nice clean interface for 
users is a good idea.  What would be the point of all those fancy things 
like metaclasses if we can't leverage them in cases like this? :-)

	I do see one possible hiccup, though: it won't be possible to use 
zero-argument super() for a subclass to override a superclass 
getter/setter, because the magic __class__ variable won't correctly 
point to the real class (i.e., the enclosing class in which the property 
inner class is defined).  And trying to use the two-argument super() may 
be confusing for the same reason.  I think trying to use super() with 
properties is already a somewhat fraught endeavor (e.g., 
http://bugs.python.org/issue14965), but it's worth thinking about how 
these approaches would work if someone wants overridable property 
getters/setters.

-- 
Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown


More information about the Python-ideas mailing list