[Python-Dev] concerns regarding callable() method (original) (raw)
Guido van Rossum guido at python.org
Sun Apr 8 17:39:30 CEST 2007
- Previous message: [Python-Dev] concerns regarding callable() method
- Next message: [Python-Dev] concerns regarding callable() method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4/8/07, Paul Pogonyshev <pogonyshev at gmx.net> wrote:
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.
Why?
Additionally consider something like
something.setcallback (x) Assume that setcallback() 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.
assert hasattr(x, 'call')
I note that callable() was introduced before all callable objects had a call attribute. This is no longer the case, so it's not needed.
Please reconsider removal of callable() or provide an adequate replacement.
What if someone passes a callable that doesn't have the expected signature?
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] concerns regarding callable() method
- Next message: [Python-Dev] concerns regarding callable() method
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]