Does python have an internal data structure with functions imported from a module?
Schüle Daniel
uval at rz.uni-karlsruhe.de
Sat Feb 18 00:01:45 EST 2006
in case you are trying it in the python shell
>>> def foo():return "test"
...
>>> import __main__
>>> __main__.__dict__["foo"]
<function foo at 0x40420c6c>
>>> __main__.__dict__["foo"]()
'test'
>>>
otherwise build your own dict with string->function mapping
op = {
"plus" : lambda x,y:x+y,
"minus" : lambda x,y:x-y,
"power" : lambda x,y:x**y,
}
op["power"](2,8)
hth, Daniel
More information about the Python-list
mailing list