Python Decorator Classes

Most examples
of creating
decorators in python,
show a function
returning an inline function. If you wanted to initialize the decorator
in some way, you'd have to write a function, initializing a function, returning
a function.

When you manage to wrap your head around it, it's not even that complicated,
but the combination of three levels of nested functions and
scope was confusing
to me at first.

I had a eureka moment, when I realized that a decorator could be any callable.
So a class implementing __call__
would suffice.

Again, this probably falls into the personal preference category, but
separating the initializing code into a
__init__ method and the
wrapping code into a __call__ method, made it a lot clearer to me.