Quantify over all functions of a module
Aahz
aahz at pythoncraft.com
Mon Dec 8 09:09:58 EST 2003
In article <mailman.221.1070890249.16879.python-list at python.org>,
Fredrik Lundh <fredrik at pythonware.com> wrote:
>> something like this might work:
>>
>> for name, func in vars(test2):
>> if not name.startswith("__") and callable(func):
>> func_list.append(func)
>
>ahem. better make that:
>
> for name, func in vars(test2).items():
> if not name.startswith("__") and callable(func):
> func_list.append(func)
...and if you wanna show off your Python 2.2+ knowledge, make that
iteritems(). ;-)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Weinberg's Second Law: If builders built buildings the way programmers wrote
programs, then the first woodpecker that came along would destroy civilization.
More information about the Python-list
mailing list