I want to create a decorator function to operate on a python class, with the ability to pass additional arguments. I want to do that before the class gets instantiated. Here is my approach:
def register(x,a):
print x,a
@register(5)
class Foo(object):
pass
with x being the class and a the additional argument. But I get a
TypeError: register() takes exactly 2 arguments (1 given)
What I want is some way to get hold of the class Foo and additional arguments at the time the class is defined, before the class is instantiated.
a), and make that function return a decorator that accepts one argument (the class).,aabove, and the output is<class '__main__.Foo'>.