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/)
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