Re: [Python-Dev] PEP 463: Exception-catching expressions

2014年2月22日 01:22:56 -0800

On 2014年2月22日 16:12:27 +0900
"Stephen J. Turnbull" <[email protected]> wrote:
> 
> Note in support: I originally thought that "get" methods would be more
> efficient, but since Nick pointed out that "haveattr" is implemented
> by catching the exception (Yikes! LBYL implemented by using EAFP!), I
> assume that get methods also are (explicitly or implicitly)
> implemented that way.
Well, the only way to know that a key (or attribute) exists is to do
the lookup. What else would you suggest?
And, yes, EAFP can avoid race conditions and the like (besides being
more efficient with non-trivial keys).
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
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