I would like to ask how one determines the type of an object in python. I know how to do that “normally”, e.g.,
import types
def f(x):
return x
isinstance(f, types.FunctionType)
returns true. But what, if I have only a string containing ‘f’, say a = ‘f’. What should I do with a? How do I figure out, whether the object specified by a string is a function, or whatever? And before anyone asks, it is a parser, and that is why I don’t know whether ‘f’ is a function;)
Thanks,
v923z
You can look up the name in
globals()(the global symbol table andlocals()(the local symbol table):