On Thu, Nov 6, 2014 at 1:10 AM, Nick Coghlan <ncogh...@gmail.com> wrote:

> Right. Especially in a ducktyping context, AttributeError and TypeError
> are often functionally equivalent - it usually isn't worthwhile adding code
> specifically to turn one into the other.
>
Yeah, these are so often interchangeable that I wish they had a common
ancestor. Then again when you are catching these you might as well be
catching all exceptions.

> The case that doesn't throw an exception at all seems a little strange,
> but I haven't looked into the details.
>
It comes from a simple approach to creating an intersection; paraphrasing,
the code does this:

def intesection(a, b):
    result = set()
    for x in a:
        if x in b:
            result.add(x)
    return result

If a is empty this never looks at b. I think it's okay not to raise in this
case (though it would also be okay if it *did* raise).

-- 
--Guido van Rossum (python.org/~guido)
_______________________________________________
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