extract method with generators
showell30 at yahoo.com
Fri Oct 15 07:02:55 CEST 2010
On Oct 14, 8:45 pm, Cameron Simpson <c... at zip.com.au> wrote:
> On 14Oct2010 20:11, Steve Howell <showel... at yahoo.com> wrote:
> | Is there a way to extract code out of a generator function f() into
> | g() and be able to have f() yield g()'s result without this idiom?:
> | for g_result in g():
> | yield g_result
> | It feels like a clumsy hindrance to refactoring, to have to introduce
> | a local variable and a loop.
> This sounds like the "yield from" proposal that had discussion some
> months ago. Your above idiom would become:
> yield from g()
> See PEP 380:
> Short answer, not available yet.
Very interesting, thanks.
More information about the Python-list