flattening lists

MRAB python at mrabarnett.plus.com
Tue Oct 11 19:26:10 EDT 2022


On 2022-10-11 21:09, Stefan Ram wrote:
> ram at zedat.fu-berlin.de (Stefan Ram) writes:
>>. I never understood "yield from" until just now, when I was
>>thinking, "Maybe this could be the piece that fits in here!"
> 
>    PS: If I'm starting to think about it: Having succeeded
>    after using it by trial in one case does not mean that I
>    have understood it!
> 
> 
This:

     yield from iterable

is equivalent to:

     for item in iterable:
         yield item

but is more efficient.

That's really all you need to know!



More information about the Python-list mailing list