Since we're talking about class decorators, I have a question about
function and instancemethod objects. The following code works<br><br>class Root(object):<br> def index(self):<br> return "Hello World!"
<br> index.exposed = True<br><br>but this code<br><br>class Root(object):<br> def index(self):<br> return "Hello World!"<br>index.exposed = True<br><br>gives the following exception<br><br>Traceback (most recent call last):
<br> File "<stdin>", line 1, in <module><br>AttributeError: 'instancemethod' object has no attribute 'exposed'
<br><br>I can tell that instancemethods can't have attributes added to
them outside of their class definition. Is this part of the Python
language spec, or just an implementation detail of CPython?<br><br>I
bring this up here because it makes writing certain class decorators
much more annoying. For example, if I want to write a class decorator
that will set "exposed=True" for every method of a class, I must resort
to shenanigans.
<br><font color="#888888"><font color="#888888"><br>- Eli</font></font><br><br>