[Python-ideas] return value of yield expressions

Ron Adam ron3200 at gmail.com
Wed Sep 14 07:01:06 CEST 2011


On Wed, 2011-09-14 at 13:41 +1000, Nick Coghlan wrote:
> On Wed, Sep 14, 2011 at 3:23 AM, Ron Adam <ron3200 at gmail.com> wrote:
> > If we could get the functions arguments when a function is done instead
> > of getting the return value.  (The modified function arguments object is
> > the return value in this case.)
> >
> >      fargs = &foo(a, b, c, d=4)
> 
> This use case is covered by the bind() method in PEP 362 [1]:
> 
>     foo_signature = inspect.signature(foo)
>     fargs = foo_signature.bind(a, b, c, d=4)
> 
> [1] http://www.python.org/dev/peps/pep-0362/#signature-object

It doesn't quite do the same thing, and it's not nearly as easy to use.


Regarding PEP 362:

The signature function gets the signature object from the target
function, ok,  The  use case in the pep describes binding and
introspecting the signature object for various purposes, which is a nice
thing to be able to do.   But after that, it just calls the functions
with the same *args and **kwds that was used to bind the signature.   So
it's unpacking args and kwds a second time.  

Will there be a way to reuse the bound signature object with a function
directly without unpacking it?
     


Cheers,
    Ron

(My replies are still taking more than 6 to 8 hours to show up on the
list?   I changed my email address recently,  The old one no longer
works as I chose not to renew the domain name.)








More information about the Python-ideas mailing list