write a recognizer
Peter Otten
__peter__ at web.de
Thu Feb 12 11:08:12 EST 2004
max khesin wrote:
> This is cool. Curious (my py object recall is a bit stale): would this
> solution work for a class that derives from Recognizer (and implements
> an 'is_' method)?
No, but you can use the following instead of dir(...) in the for loop of
__init__():
(copied from cmd.py in the libarary)
def get_names(self):
# Inheritance says we have to look in class and
# base classes; order is not important.
names = []
classes = [self.__class__]
while classes:
aclass = classes.pop(0)
if aclass.__bases__:
classes = classes + list(aclass.__bases__)
names = names + dir(aclass)
return names
Peter
More information about the Python-list
mailing list