On 06-12-2010 16:04, Jean-Michel Pichavant wrote: > Stef Mientki wrote: >> On 06-12-2010 12:08, Ben Finney wrote: >>> Stef Mientki <stef.mien...@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. >>> >>> >> Thanks Ben, >> here some more explanation. >> >> I've a number of (dynamic) applications, >> launched from a central wrapper. >> All these modules have a class "Start", which launches the application and >> embeds them in the >> wrapper application. >> >> Module 1: >> class Start (): >> .... >> >> Module 2: >> @auth >> class Start (): >> ... >> >> When the wrapper application is started, it looks for all dynamic modules >> (without importing them), >> and list these application in a hierarchical tree. >> In the above axmple, >> I would like to know that the class "Start" in Module 2 has the decorator >> "Auth", *without >> importing the module*, >> (so depending on the user logged in, I can decide to add or not add the >> module to the >> hierarchical tree). >> >> thanks, >> Stef Mientki >> >> >> >> > You best bet is to parse the source file. thanks, I was afraid of that. cheers, Stef > > JM
-- http://mail.python.org/mailman/listinfo/python-list