Modifying signature of ctor in class

gal kauffman gal.kauffman at gmail.com
Thu Sep 24 18:07:06 EDT 2015


Sorry, you really can't give FunctionType an argument list.
Maybe you can wrap the function with a callable object, this way you can
change the argument list returned, and doest have to eval or compile code.
On Sep 25, 2015 12:46 AM, "Joseph L. Casale" <jcasale at activenetwerx.com>
wrote:

> > I don't think you can easily change the function's own definition,
> > other than by using eval (or equivalent shenanigans, like crafting
> > your own bytecode); but as of Python 3.something, the help() function
> > looks for a __wrapped__ attribute and will take function args from
> > that instead of the function itself. That way, when you use
> > functools.wraps(), it copies in the docstring and stuff, and as far as
> > help() is concerned, copies in the argument list too.
> >
> > No idea whether you'll be able to do that too, but it's a fairly
> > effective way to get around the problem if you can.
>
> Hi Chris,
> That is helpful. It still leaves me with generating a string function
> and eval'ing or compiling it to swipe the sig. At the point I could
> rebuild the entire function and simply apply it.
>
> Where all but a valid sig helps is for introspection such as tab completing
> with ipython or using an IDE etc.
>
> Thanks everyone,
> jlc
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150924/a5150174/attachment.html>


More information about the Python-list mailing list