[Tutor] getattr of functions
negroup at gmail.com
Thu Nov 24 12:00:27 CET 2005
Hi all! I'm here again with a question about introspection.
My module stores a set of functions. I need to know, from another
script, if a particular function of this module "is enabled" (it
means, if it shall be executed by the caller script). I looked for
some introspective builtin/function, but I didn't find anything useful
(except func_globals, func_dict, func_code, etc, that don't help in my
This is my solution:
setattr(f1, 'enabled', True)
setattr(f2, 'enabled', False)
foo at bar:~/projects/erp/migra$ python
Python 2.3.5 (#1, Sep 6 2005, 12:53:27)
[GCC 3.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mymodule import *
This seems to work.. I wonder for better solutions.
Thanks you all!
More information about the Tutor