[Edu-sig] Using try / except: any stipulations against routine use?

Laura Creighton lac at openend.se
Wed Dec 14 20:43:54 CET 2011


I'm encouraging the use of try: except around here.  I think the 
distinction between 'routine' and 'non-routine' only makes sense if
exceptions are so terribly slower than the routine that using them for
routine use will have a terrible effect in slowness on your program.
It's like using:

string1 = string1 + newstring

inside a loop.

The reason you don't do this is not because there is something conceptually
wrong with this idea, but because it's horribly slow.  And if smarter pythons
recognise this, and emit fast code for it anyway, then that objection goes 
away, and then, well, it is a more straight forward way to code it.

So, if performance is not an issue, then I would recommend using try:
except: wherever it feels natural, and not let '20 years of knowing that
in java exceptions are horrible big and slow things to be used sparingly'
influence what feels natural.

Laura



More information about the Edu-sig mailing list