[Python-3000] PEP 3100 Comments
Antoine Pitrou
solipsis at pitrou.net
Sun May 7 15:52:49 CEST 2006
Le dimanche 07 mai 2006 à 17:47 +1200, Greg Ewing a écrit :
> Talin wrote:
>
> > 1) Getting rid of 'callable'.
> >
> > The reccomended replacement is "just call the object and catch the resulting
> > exception",
>
> No, the recommended replacement should be "redesign your API
> so that you don't need to test whether something is callable".
I think callable() can be useful for defensive coding.
For example, if your function expects a callback as argument, you can
check whether the callback is really callable before actually calling it
5 minutes (or 5 days) later.
Of course, it could be part of a signature checking API: first check if
the object is callable, then if it has the right signature.
More information about the Python-3000
mailing list