Loading functions from a file during run-time

Wensheng wenshengwang at gmail.com
Wed Feb 16 12:55:51 EST 2005


or don't use exec():
f=[getattr(fs,a) for a in dir(fs) if a[0:2]!='__' and
type(getattr(fs,a))==types.FunctionType]
>>> f
[<function negate at 0x100a00>, <function square at 0x144038>]
>>> f[0](n)
-5
>>> f[1](n)
25




More information about the Python-list mailing list