Background: Migrating from R to Python with numpy/scipy. Trying to make a little module of useful functions. In particular, I'm trying to create a recursive element-type checker.
Question: Is it possible to get a list of the current valid types in the Python environment a function is being called in?
For example, isinstance(1,int)
will return True
, isinstance(1,str)
will return False
, but isinstance(1,asdf)
will throw a NameError: name 'asdf' is not defined
i.e. int and str are defined, but asdf is not. How can I get the list of types that are defined, or names present in the current Python environment, and filter them by types?