Nick Coghlan, 08.02.2013 16:20:
> On Sat, Feb 9, 2013 at 1:06 AM, Benjamin Peterson wrote:
>> 2013/2/8 Stefan Behnel:
>>> 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?

It should call isfunction() instead of running an explicit type check.


> I assumed Stefan was wanting to use Signature.from_function() to set
> __signature__ (as soon as you do that, inspect.signature will do the
> right thing).

Absolutely.

Stefan


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to