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"
wrote:
> > I don't think you can easily chan
You can use the FunctionType class found in the types module (and its
friends) to create functions on the run.
And you can use the 'inspect' module to inspect existing functions, if you
need to base the new function on an existing one.
On Sep 24, 2015 11:28 PM, "Joseph L. Casale"
wrote:
> I have
On Thu, Sep 24, 2015 at 5:01 PM, Joseph L. Casale
wrote:
>> py> from inspect import Signature, Parameter
>> py> def foo(*args, **kwargs): pass
>> ...
>> py> foo.__signature__ = Signature([Parameter('x',
>> Parameter.POSITIONAL_OR_KEYWORD), Parameter('y',
>> Parameter.KEYWORD_ONLY)])
>> py> help(fo
> py> from inspect import Signature, Parameter
> py> def foo(*args, **kwargs): pass
> ...
> py> foo.__signature__ = Signature([Parameter('x',
> Parameter.POSITIONAL_OR_KEYWORD), Parameter('y',
> Parameter.KEYWORD_ONLY)])
> py> help(foo)
> Help on function foo in module __main__:
>
> foo(x, *, y)
On Fri, Sep 25, 2015 at 8:19 AM, Ian Kelly wrote:
> Quick and dirty example:
>
> py> from inspect import Signature, Parameter
> py> def foo(*args, **kwargs): pass
> ...
> py> foo.__signature__ = Signature([Parameter('x',
> Parameter.POSITIONAL_OR_KEYWORD), Parameter('y',
> Parameter.KEYWORD_ONLY)]
On Thu, Sep 24, 2015 at 4:10 PM, Ian Kelly wrote:
> On Thu, Sep 24, 2015 at 2:28 PM, Joseph L. Casale
> wrote:
>> I have a class factory where I dynamically add a constructor to the class
>> output.
>> The method is a closure and works just fine, however to accommodate the
>> varied
>> input it
On Thu, Sep 24, 2015 at 2:28 PM, Joseph L. Casale
wrote:
> I have a class factory where I dynamically add a constructor to the class
> output.
> The method is a closure and works just fine, however to accommodate the varied
> input its signature is (*args, **kwargs).
>
> While I modify the doc st
On Fri, Sep 25, 2015 at 7:45 AM, Joseph L. Casale
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__ a
> 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 th
> You can use the FunctionType class found in the types module (and its
> friends) to create functions on the run.
> And you can use the 'inspect' module to inspect existing functions, if you
> need to base the new function on an existing one.
Hi Gal,
Seems the types module docs do not even have
On Fri, Sep 25, 2015 at 6:28 AM, Joseph L. Casale
wrote:
> I have a class factory where I dynamically add a constructor to the class
> output.
> The method is a closure and works just fine, however to accommodate the varied
> input its signature is (*args, **kwargs).
>
> While I modify the doc st
I have a class factory where I dynamically add a constructor to the class
output.
The method is a closure and works just fine, however to accommodate the varied
input its signature is (*args, **kwargs).
While I modify the doc strings, the ctor sig is not optimal. Without building
this a string an
12 matches
Mail list logo