[Python-3000] PEP 3100 Comments

Barry Warsaw barry at python.org
Mon May 8 21:55:03 CEST 2006


On Mon, 2006-05-08 at 09:47 -0600, Steven Bethard wrote:
> On 5/8/06, Barry Warsaw <barry at python.org> wrote:
> > Perhaps then, if we get rid of callable()/PyCallable_Check() it would be
> > useful to add a NotCallableError (as a subclass of TypeError?) that
> > would get thrown should you try to call something that's not callable.
> > The argument to the exception would be the thing you tried to
> > erroneously called.
> 
> +1.  It'd certainly be nice to be able to tell the difference between
> the following two TypeErrors:
> 
>     >>> def s():
>     ...     raise TypeError()
>     ...
>     >>> 's'()
>     Traceback (most recent call last):
>       File "<interactive input>", line 1, in ?
>     TypeError: 'str' object is not callable
>     >>> s()
>     Traceback (most recent call last):
>       File "<interactive input>", line 1, in ?
>       File "<interactive input>", line 2, in s
>     TypeError

BTW, this is something we could add for Python 2.x if we wanted to.
Since NotCallableError would be a subclass of TypeError, all existing
code should continue to work.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-3000/attachments/20060508/0c8e8eaa/attachment.pgp 


More information about the Python-3000 mailing list