[Python-Dev] concerns regarding callable() method

Paul Pogonyshev pogonyshev at gmx.net
Sun Apr 8 14:10:32 CEST 2007


Hi,

I have seen in PEP 3100 that callable() function is planned to be
removed in Python 3000 with this replacement: "just call the object
and catch the exception???".  For one, the object (if it is
callable) can raise exception itself, so you need to somehow to
differentiate between exception raised inside its __call__ and
exception raised if object is not callable to begin with.

Additionally consider something like

	something.set_callback (x)

Assume that set_callback() wants to check if `x' is callable at
all, to raise exception early and make error tracking easier.
Currently, you can

	assert callable (x)

But if callable() is removed, there is no apparent replacement.  Of
course, you cannot call `x' since it might have side-effects or be
slow etc.

Please reconsider removal of callable() or provide an adequate
replacement.

Paul


More information about the Python-Dev mailing list