Re:A crash course in Python “comprehensions” and “generators”
by memco on Saturday December 10, 2022 @02:47AM
(#33930814)
Knew about it, but didn't quite understand how to use send until I read through the link you posted. Thanks for that!
Regarding that article specifically I think it could've done better service to 'yield from' had it mentioned recursive generators. One example would be flattening nested lists: have a flatten function that checks if its argument is iterable: if not just yield the thing else yield from flatten for every item in the iterable.
Regarding that article specifically I think it could've done better service to 'yield from' had it mentioned recursive generators. One example would be flattening nested lists: have a flatten function that checks if its argument is iterable: if not just yield the thing else yield from flatten for every item in the iterable.