A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-November/136910.html below:

[Python-Dev] Real-world use of Counter

[Python-Dev] Real-world use of Counter [Python-Dev] Real-world use of CounterGuido van Rossum guido at python.org
Thu Nov 6 16:46:39 CET 2014
On Thu, Nov 6, 2014 at 1:10 AM, Nick Coghlan <ncoghlan at 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20141106/f7dfb46f/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4