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
since it puts the normal and exceptional values next
to each other, and relegates the exception type (which
is of much less interest) to a trailing aside.
--
Greg
_______________________________________________
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