Hello :)This is my first mail here, I had an idea that I'd like to propose.
The `getargspec` function in the `inspect` module enforces the input parameter 
to be either a method or a function.
    def getargspec(func):        """Get the names and default values of a 
function's arguments.            A tuple of four things is returned: (args, 
varargs, varkw, defaults).        'args' is a list of the argument names (it 
may contain nested lists).        'varargs' and 'varkw' are the names of the * 
and ** arguments or None.        'defaults' is an n-tuple of the default values 
of the last n arguments.        """    
        if ismethod(func):            func = func.im_func        if not 
isfunction(func):            raise TypeError('{!r} is not a Python 
function'.format(func))        args, varargs, varkw = getargs(func.func_code)   
     return ArgSpec(args, varargs, varkw, func.func_defaults)
Passing in a callable which is not a function causes a TypeError to be raised.
I think in this case any callable should be allowed, allowing classes and 
callable objects as well.We can switch on whether `func` is a function, a class 
or a callable object, and pass into `getargs` the appropriate value.
What is your opinion?Thank you
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to