Finding decorators in a file

Andrew West andrewwest at gmail.com
Fri Oct 26 21:14:18 EDT 2007


Probably a bit of weird question. I realise decorators shouldn't be
executed until the function they are defined with are called,  but is
there anyway for me to find all the decorates declared in a file when
I import it? Or perhaps anyway to find the decorators by loading the
file by other methods (with out simply parsing it by hand).

Basically what I'm looking for is a way to, given a python file, look
through that file and find all the decorators and the associated
functions, that includes any arguments that the decorator has.

Sorry if this has been asked before but I've googled no end and come
up with nothing so far.




More information about the Python-list mailing list