module functions list
mark hellewell
mark.hellewell at gmail.com
Wed Aug 25 08:17:53 EDT 2004
Hi,
You could use a list comprehension coupled with a filter:
functionList = [function for function in dir(objectName) \
if callable(getattr(objectName,function))]
mark
On Wed, 25 Aug 2004 13:45:11 +0200, Diez B. Roggisch <deetsnospam at web.de> wrote:
> Hi,
>
> this strikes me as a pretty basic question, but google didn't help, so I'm
> asking it here:
>
> How do I get a list of functions defined in a module in the module itself?
> Like this:
>
> --- module functions.py
> def foo():
> return 1
>
> def bar():
> return 1
>
> def all_functions():
> return <some magic code that yields [foo, bar]>
>
> ---
>
> The application for this is that I want a bunch of predefined functions for
> a small expression interpreter of mine to be collected in one module and
> get them all without an explicit "registration" process.
>
> Any ideas?
>
> --
> Regards,
>
> Diez B. Roggisch
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list