On 02/21/2014 05:21 PM, Steven D'Aprano wrote:
On Sat, Feb 22, 2014 at 01:15:13PM +1300, Greg Ewing wrote:

With an except expression, it could be written:

    result = computation(int(arg)
       except ValueError: abort("Invalid int"))

Nice example! Except I'd lay the code out a bit better to emphasise
which part is being guarded:

     result = computation(
                  int(arg) except ValueError: abort("Invalid int")
                  )

Actually, not quite so nice as I first thought, since you're relying on
the side-effects of abort() rather than returning a value.

Think of it rather as transforming the exception to be more useful.

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to