E
Edward K. Ream
Hi,
I would like to create a dictionary of all the classes that exist while my
app is running. This is the best I can do:
def defineClassesDict (self):
self.allClassesDict = {}
for z in gc.get_objects():
t = type(z)
if t == types.ClassType:
name = z.__name__
elif t == types.InstanceType:
name = z.__class__.__name__
elif repr(t).startswith('<class'): # A wretched kludge.
name = z.__class__.__name__
elif t == types.TypeType:
name =z.__name__
else:
name = None
if name:
self.allClassesDict [name] = z
This works, but it relies on a wretched (and slow) kludge, namely the test:
repr(t).startswith('<class')
There seems to be a hole in the types module. Can anyone suggest a better
approach? Thanks.
Edward
I would like to create a dictionary of all the classes that exist while my
app is running. This is the best I can do:
def defineClassesDict (self):
self.allClassesDict = {}
for z in gc.get_objects():
t = type(z)
if t == types.ClassType:
name = z.__name__
elif t == types.InstanceType:
name = z.__class__.__name__
elif repr(t).startswith('<class'): # A wretched kludge.
name = z.__class__.__name__
elif t == types.TypeType:
name =z.__name__
else:
name = None
if name:
self.allClassesDict [name] = z
This works, but it relies on a wretched (and slow) kludge, namely the test:
repr(t).startswith('<class')
There seems to be a hole in the types module. Can anyone suggest a better
approach? Thanks.
Edward