Get List of Classes
Tim Chase
python.list at tim.thechases.com
Mon Jun 26 11:56:37 EDT 2006
>> I couldn't find any nice method for determining if a
>> variable referenced a module other than checking to see if
>> that item had both a "__file__" and a "__name__" attribute.
>
> Why not :
>
> In [8]: import types, sys
>
> In [9]: isinstance(sys, types.ModuleType)
> Out[9]: True
Yes...this is the best way to do it. I hadn't explored (or even
noticed, before your reply) the "types" module, which seems to
have a large toolset for doing exactly what I wanted to. Thanks!
A good programming language has users asking "how did I miss
that?" rather than "why can't I make it do what I want?". Yet
another feather in Python's cap.
-tkc
More information about the Python-list
mailing list