Is there any shorthand for 'yield all the output from a generator'?

后端 未结 3 507
死守一世寂寞
死守一世寂寞 2021-01-17 07:34

Is there a one-line expression for:

for thing in generator:
    yield thing

I tried yield generator to no avail.

3条回答
  •  清酒与你
    2021-01-17 08:27

    Here is a simple one-liner valid in Python 2.5+ as requested ;-):

    for thing in generator: yield thing
    

提交回复
热议问题