On 8/8/2013 12:20 PM, adam.pre...@gmail.com wrote:
On Thursday, August 8, 2013 3:04:30 AM UTC-5, Terry Reedy wrote:
def test(f): f.__class__.__dict__['test_'+f.__name__]
Sorry, f.__class__ is 'function', not the enclosing class. A decorator for a method could not get the enclosing class name until 3.3, when it would be part of f.__qualname__.
Use one of the other suggestions.
Just for giggles I can mess around with those exact lines, but I did get spanked trying to do something similar. I couldn't reference __class__ for some reason (Python 2.7 problem?).
In 2.x, old-style classes and instances thereof do not have .__class__. All other objects do, as far as I know.
-- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list