3 ms·
> this code doesn't contain any list comprehensions, for example It does contain a generator expression though, which is the same as a list comprehension in ge
by Izkata 7y ago
> this code doesn't contain any list comprehensions, for example
It does contain a generator expression though, which is the same as a list comprehension in general structure, but slightly more confusing because it doesn't have the relationship to lists that square brackets in a list comprehension would have given it.
- kragen 7y agoYes, it shares the structure of a list comprehension, but has different semantics. In this case a listcomp would have worked just as well. My point, though, was that not being able to tell the difference was a key "tell" that the comment author was not very familiar with Python — in some contexts, that would tend to undermine credibility in their comment (and then it would be rude to point it out), but in this context, it probably makes their opinion more objective.
- elcritch 7y agoGood point, though it's less my familiarity with Python and more that I tend to simplify and call generator expressions as list comprehensions unless the laziness is important to call out (meta laziness there? ;) ). Mainly since L.C.'s were first and describing the differences is tedious.