A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-April/072516.html below:

[Python-Dev] concerns regarding callable() method

[Python-Dev] concerns regarding callable() method [Python-Dev] concerns regarding callable() methodGuido van Rossum guido at python.org
Sun Apr 8 17:39:30 CEST 2007
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.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.

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/)
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4