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/2005-October/057654.html below:

[Python-Dev] Proposed resolutions for open PEP 343 issues

[Python-Dev] Proposed resolutions for open PEP 343 issues [Python-Dev] Proposed resolutions for open PEP 343 issuesGuido van Rossum guido at python.org
Wed Oct 26 00:05:25 CEST 2005
On 10/25/05, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Maybe there's a design principle in there somewhere:
>
>    Failed duck-typing -> AttributeError (or TypeError for complex checks)
>    Failed instance or subtype check -> TypeError

Doesn't convince me.

If there are principles at work here (and not just coincidences), they
are (a) don't  lightly replace an exception by another, and (b) don't
raise AttributeError; the getattr operation raise it for you. (a) says
that we should let the AttributeError bubble up in the case of the
with-statement; (b) explains why you see TypeError when a slot isn't
filled.

> Most of the functions in abstract.c handle complex protocols, so a simple
> attribute error wouldn't convey the necessary meaning. The context protocol,
> on the other hand, is fairly simple, and an AttributeError tells you
> everything you really need to know.

That's what I've been saying all the time. :-)

--
--Guido van Rossum (home page: http://www.python.org/~guido/)
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