yield_all needed in Python

Jeremy Bowers jerf at jerf.org
Thu Mar 3 23:11:54 CET 2005

On Thu, 03 Mar 2005 20:47:42 +0000, Paul Moore wrote:
> This can probably be tidied up and improved, but it may be a
> reasonable workaround for something like the original example.

This is why even though in some sense I'd love to see yield *expr, I can't
imagine it's going to get into the language itself; it's too easy to do it
yourself, or provide a library function to do it (which would A: Be a lot
easier if we had some sort of "iterable" interface support and B: Be a
great demonstration of something useful that really needs protocol support
to come off right, because isinstance(something, GeneratorType) isn't
sufficient in general).

Abstractly I like the star syntax, but concretely I'm not a big fan of
adding something to the language that can be done right now with a fairly
short function/generator and hardly even any extra keystrokes to invoke it
when done right, and that overrides my abstract appreciation.

More information about the Python-list mailing list