[Python-3000] Using *a for packing in lists and other places

Thomas Wouters thomas at python.org
Sat Mar 15 22:03:23 CET 2008


On Sat, Mar 15, 2008 at 12:44 PM, Neville Grech Neville Grech <
nevillegrech at gmail.com> wrote:

> What about co-routines?
>

They're out of luck. Your code below doesn't work (the 'yield *it' syntax
always results in None; any sends are discarded.) I do not think collecting
a (potentially ever-growing) list of results is really the right thing to
do, do you? :-) Something that *might* make sense is to forward any sends on
to the inner iterator, but that means it would always have to be a
generator, and at that point you're really much better off explicitly
defining the behaviour (by looping yourself.)


>
> >>> def coroutine():
> ...     a, b = (yield *[1,2])
> ...    print (a)
> ...    print (b)
> ...
> >>> cr=coroutine()
> >>> next(cr)
> 1
> >>> cr.send(3)
> 2
> >>> cr.send(4)
> 3
> 4
> >>>
>
>
> On Sat, Mar 15, 2008 at 7:21 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>
> > Guido van Rossum wrote:
> > > What do people think?
> >
> > I think this idea (or variants thereof) has been suggested a few times
> > over the years, and I don't think the arguments against it have ever
> > been particularly compelling. The difference this time is that PEP 3132
> > has done the work of thrashing out some of the semantic details, and
> > Thomas has provided an actual working patch to make it happen :)
> >
> > So +1 here, even though I expect style guides will end up discouraging
> > some of the more obscure possible uses.
> >
> > Cheers,
> > Nick.
> >
> > --
> > Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
> > ---------------------------------------------------------------
> >             http://www.boredomandlaziness.org
> > _______________________________________________
> > Python-3000 mailing list
> > Python-3000 at python.org
> > http://mail.python.org/mailman/listinfo/python-3000
> > Unsubscribe:
> > http://mail.python.org/mailman/options/python-3000/nevillegrech%40gmail.com
> >
>
>
>
> --
> Regards,
> Neville Grech
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe:
> http://mail.python.org/mailman/options/python-3000/thomas%40python.org
>
>


-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20080315/c272f61e/attachment-0001.htm 


More information about the Python-3000 mailing list