John Salerno escribió: > Alexis Roda wrote: >> >> > The >> > try block seems nicer because it doesn't have such an ugly-looking >> check >> > to make. >> > > Why do you think that this try block is preferred over what I have (if I > were to stick with the try block)?
My example has nothing to do with your script, apart from trying to illustrate why I think you should use "if" instead of "try" with a kind of "reductio ad absurdum" reasoning. To me i == 0 seems as ugly as len(sys.argv) == 1 (*), so, according to your statement about ugly checks, you should avoid code like: if i == 0 : do_something_if_zero() and write something like: try: x = 1 / i except ZeroDivisionError : do_something_if_zero() but probably you wouldn't, the "if" block seems more "natural" than the convoluted "try" block, so ... Regards (*) len(sys.argv) == 1 is exactly the same as len(sys.argv) - 1 == 0 -- http://mail.python.org/mailman/listinfo/python-list