>> 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
Le lundi 26 juin 2006 17:25, Tim Chase a écrit :
> 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.M
Wow, more than I had asked for, thank you Tim!
I ended up doing this:
def isClass(object):
if 'classobj' in str(type(object)):
return 1
elif "'type'" in str(type(object)):
return 1
else:
return 0
def listClasses():
classes = []
for eachobj in globals().
> Is there a method or attribute I can use to get a list of
> classes defined or in-use within my python program? I tried
> using pyclbr and readmodule but for reason that is dogslow.
Well, given that so much in python is considered a class, the
somewhat crude code below walks an object/module a
Is there a method or attribute I can use to get a list of classes
defined or in-use within my python program? I tried using pyclbr and
readmodule but for reason that is dogslow. Thanks in advance
DigiO
--
http://mail.python.org/mailman/listinfo/python-list