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/2013-February/123882.html below:

[Python-Dev] Why does Signature.from_function() have to check the type of its argument?

[Python-Dev] Why does Signature.from_function() have to check the type of its argument? [Python-Dev] Why does Signature.from_function() have to check the type of its argument?Benjamin Peterson benjamin at python.org
Fri Feb 8 16:06:09 CET 2013
2013/2/8 Stefan Behnel <stefan_ml at behnel.de>:
> Hi,
>
> I'm wondering about the purpose of this code in
> inspect.Signature.from_function():
>
> """
>     if not isinstance(func, types.FunctionType):
>         raise TypeError('{!r} is not a Python function'.format(func))
> """
>
> Is there any reason why this method would have to explicitly check the type
> of its argument? Why can't it just accept any object that quacks like a
> function?

The signature() function checks for types.FunctionType in order to
call Signature.from_function(). How would you reimplement that?

-- 
Regards,
Benjamin
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