On 02/21/2014 03:29 PM, Greg Ewing wrote:
Antoine Pitrou wrote:

   lst = [1, 2]
   value = lst[2] except IndexError: "No value"

the gain in concision is counterbalanced by a loss in
readability,

This version might be more readable:

    value = lst[2] except "No value" if IndexError

It does read nicely, and is fine for the single, non-nested, case (which is probably the vast majority), but how would it handle nested exceptions?

--
~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