[Python-Dev] Tricky way of of creating a generator via a comprehension expression (original) (raw)
Paul Moore p.f.moore at gmail.com
Thu Nov 23 07:50:35 EST 2017
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 23 November 2017 at 12:42, Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
See e.g. http://www.tornadoweb.org/en/stable/gen.html
Great, so I open this page and see this code: results = [] for future in listoffutures: results.append(yield future) Interesting, why don't they use a comprehension for this and instead need to invent a whole
tornado.gen.multi
function?
Because yield expressions in comprehensions are difficult to understand, and the loop form is easy to understand? :-) (Certainly I didn't find the explanation in that page confusing, I don't know if I'd have found a comprehension form confusing, but I suspect I might have...)
Paul
- Previous message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Next message (by thread): [Python-Dev] Tricky way of of creating a generator via a comprehension expression
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]