On 07/10/2013 02:01 PM, Nachi Ueno wrote:
HI folks

I would like to ask the review criteria in the community.

Should we use exception for non-exceptional cases when we can use
  parameter checking?

Example1:  Default value for array index

try:
    value = list[5]
except IndexError:
     value = 'default_value'

This can be also written as,

      list_a[3] if len(list_a) > 3 else 'default_value'

Both of these are fine.  Neither deserves to be banned.

But LBYL is often naive in the face of concurrency. Just because something was true a microsecond ago doesn't mean it's still true. Exceptions are often more robust.

--
David Ripton   Red Hat   drip...@redhat.com

_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to