[Python-ideas] Fix that broken callable builtin

Ethan Furman ethan at stoneleaf.us
Fri Apr 17 23:10:30 CEST 2015


On 04/18, Ionel Cristian Mărieș wrote:

> Also there's the issue about not being able to implement a true proxy (as
> outlined before).

Proxies are a bit of a pain.  But you can create your own callable function.

Something like (untested):

def callable(obj):
    try:
        func = obj.__call__
        return True
    except AttributeError:
        return False

--
~Ethan~


More information about the Python-ideas mailing list