I'm writing a parser for english language. This is a simple function to identify, what kind of sentence we have. Do you think, this class wrapping is right to represent the result of the function? Further parsing then checks isinstance(text, Declarative).
------------------- class Sentence(str): pass class Declarative(Sentence): pass class Question(Sentence): pass class Command(Sentence): pass def identify_sentence(text): text = text.strip() if text[-1] == '.': return Declarative(text) elif text[-1] == '!': return Command(text) elif text[-1] == '?': return Question(text) return text ------------------- At first i just returned the class, then i decided to derive Sentence from str, so i can insert the text as well. -- http://mail.python.org/mailman/listinfo/python-list