if result is None: print "error parsing stream" elif result: print "result pass" else: print "result fail"
keep it simple and explicit. Of course, you can predefine the dictionary.
messages = {None: 'error', True: 'pass', False: 'fail'} print messages[result]
If you plan to change your simulate function to include more return codes, saving this code may be a problem.
simulate can also throw an exception when parsing errors, in which case you will either catch it here or let it spread the level up, and the print bit will be reduced to a single-line if-else statement.
SilentGhost Jan 07 '10 at 13:33 2010-01-07 13:33
source share