write a recognizer

Klaus Neuner klaus_neuner82 at yahoo.de
Thu Feb 12 04:05:29 EST 2004


Hello,

I want to write a class Recognizer, like so:

class Recognizer(object):

    def is_of_category_1(self, token):
        if token == 1:
            return "1"
        else:
            return False

    def is_of_category_2(self, token):
        if token == 2:
            return "2"
        else:
            return False

    def recognize(self, token):
        for fun in <?>:
            result = apply(fun, token)
            if result:
                return result
        return False

What do I have to write instead of <?>? 
Or: How should I design the recognizer, if the above design is not good? 

Klaus



More information about the Python-list mailing list