[IronPython] staticmethod / classmethod and setattr

Curt Hagenlocher curt at hagenlocher.org
Thu Feb 7 00:25:05 CET 2008


This is really more of a Python question than an IronPython question, but
I'm not currently on any non-Iron Python lists. :)

The following definition results in an error under both CPython 2.5 and
IronPython.  Decorating a method as static or class prevents attributes
being set on the resulting definition.

def decorate(obj):
    obj.decorated = True
    return obj

class X:
    @decorate
    @staticmethod
    def foo():
        pass

Does anyone know the "why" of this behavior?

I can work around this problem by declaring the decorators in the opposite
order, but it seems like an odd imposition to put on the consumers of the
code in question.  I'm worried that I'm missing something about the expected
semantics of these standard functions.

--
Curt Hagenlocher
curt at hagenlocher.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080206/52213ff4/attachment.html>


More information about the Ironpython-users mailing list