critique this little script, if you like
John Salerno
johnjsal at NOSPAMgmail.com
Mon May 1 10:38:51 EDT 2006
Alexis Roda wrote:
> 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()
Why do you think that this try block is preferred over what I have (if I
were to stick with the try block)?
More information about the Python-list
mailing list