[Python-3000] callable()

Calvin Spealman ironfroggy at gmail.com
Mon Jul 17 18:49:33 CEST 2006


I second that removal of callable() would be a bad idea. There are too many
cases where it is not feasable to "just call the object and catch the
exception". In the cases where the call would not happen until later than
the test for callability, it would require then that any state changes
caused before the call would be reversed if calling the object raised any
error, and sometimes that is not even possible. Further, it ignores all
cases where we are simply introspecting and do not want any side effects
from said introspection.


On 7/17/06, Andrew Koenig <ark at acm.org> wrote:
>
> I note in PEP 3000 the proposal to remove callable(), with the comment
> "just
> call the object and catch the exception."
>
> I think that's a bad idea, because it takes away the ability to separate
> the
> callability test from the first call.  As a simple example, suppose you're
>
> writing a function that you expect to be given a function as one of its
> arguments:
>
>         def foo(bar, fun):
>                 assert callable(fun)
>                 # ...
>
> It might be that foo doesn't actually call fun until much later.
> Nevertheless, from a testing viewpoint, it would be better to detect the
> error immediately of passing something that can't be called.
>
> If you didn't have callable, how would you write this example?
>
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/ironfroggy%40gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20060717/36034d33/attachment.htm 


More information about the Python-3000 mailing list