On 12/17/09 16:36 , Ethan Jucovy wrote:
> Hi,
>
> On Thu, Dec 17, 2009 at 10:15 AM, Martijn Faassen
> <faas...@startifact.com>  wrote:
>> * It'd be nice if __call__ came back with a LookupError instead of a
>> TypeError, but how to get from A to B without breakage?
>
> Maybe I've misunderstanding, but what's the advantage of making
> IFoo(x) raise a LookupError instead of a TypeError?  I've tried to
> follow the thread but I've been confused about this.  I do rely on
> catching TypeErrors quite often in my code -- I had thought it was
> intended as part of the API.
>
> I like that treating it as typecasting instead of lookup blurs the
> conceptual distinction between "adapting x to IFoo" and "asserting x
> implements IFoo directly" -- when I actually want to know one or the
> other I can use explicit adaptation or check providedBy.  In other
> words I use IFoo(x) when I don't care whether IFoo(x) == x.
>
> I suppose it's not a big deal but catching LookupErrors instead would
> feel somewhat less semantic for the way I think about this.  But from
> what I've caught of the larger thread it sounds like I'm in the
> minority here.

Perhapse LookupError should be a subclass of TypeError.

Wichert.
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to