critique this little script, if you like
Alexis Roda
arv.nntp at gmail.com
Mon May 1 06:27:33 EDT 2006
John Salerno escribió:
> 2. Between the if block or the try block, which is more Pythonic?
Since the command line argument is optional I don't think it should be
considered and exceptional condition if it's missing, so the "if" block
looks better to me. No idea if this is more pythonic.
> The
> try block seems nicer because it doesn't have such an ugly-looking check
> to make.
Ok, so you should do:
try:
x = 1/i
except ZeroDivisionError :
do_something_if_zero()
instead of
if (i == 0) :
do_something_if_zero()
HTH
More information about the Python-list
mailing list