Self descibing scripts

Fredrik Lundh fredrik at pythonware.com
Mon Apr 2 09:31:48 EDT 2001


Neil Benn wrote:

>             I'm looking at a way to make pyhton scripts self describing.
> I'm thinking of something similar to java's reflection.
>
>     Has anyone tried this, I could code a list to be returned of the
> functions in the script but that's a bit messy - any help/ideas would be
> greatly appreciated!

how about dir?

>>> import math
>>> dir(math)
['__doc__', '__name__', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh',
'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log', 'log10',
'modf', 'pi', 'pow', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']

Cheers /F





More information about the Python-list mailing list