> On Behalf Of Andrew West
> 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.

The inspect module has a function called "findsource"

import inspect
import my_module

lines, line_num = inspect.findsource(my_module)

decorated_lines = [num
                   for num, line in enumerate(lines)
                   if line.strip().startswith("@")]

Probably a little more complicated than that -- like what if a function has
two decorators? -- but I think the basic idea will work.

Regards,
Ryan Ginstrom

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to