is it possible to see if a class has a decorator ?
Ben Finney
ben+python at benfinney.id.au
Mon Dec 6 06:08:33 EST 2010
Stef Mientki <stef.mientki at gmail.com> writes:
> I would like to know if a class definition has a decorator,
I'm not sure what this question means.
Applying a decorator to a class definition produces a normal class.
Classes don't “have” decorators; classes can be returned by a decorator
function, but AFAIK the resulting class doesn't “have” the decorator in
any sense.
> is that possible ?
The return value of a decorator isn't special in any way, AFAIK.
Any function can return a class object or a function object, and any
function can be used as a decorator.
The only thing that makes a function a decorator is how it is used in
the code; but it doesn't leave a trace that I know of.
Now, what is it you're trying to do? Perhaps there's a better solution
we can come up with.
--
\ “Pinky, are you pondering what I'm pondering?” “I think so, |
`\ Brain, but there's still a bug stuck in here from last time.” |
_o__) —_Pinky and The Brain_ |
Ben Finney
More information about the Python-list
mailing list