Python equivalents to MATLAB str2func, func2str, ischar, isfunc?
a.schmolck at gmail.com
Wed Mar 14 19:33:51 CET 2007
"dmitrey" <openopt at ukr.net> writes:
> Thank you
> (however in MATLAB ischar is the same as isstr)
> but what if I don't know the name of module?
> I.e. I have
> def myfunc(param): ...
> #where param can be both funcName or a function, and I want to obtain
> both name and func, something like
> if isinstance(param, basestring):
> func, funcName = <something>, param
> else: func, funcName = param, param.__name__
> what should I type instead of <something>?
globals()[param] (I assume you don't want a local function, should one exist?)
More information about the Python-list