Proposed new syntax
Steve D'Aprano
steve+python at pearwood.info
Fri Aug 18 20:25:29 EDT 2017
On Fri, 18 Aug 2017 11:46 pm, Rustom Mody wrote:
> My issue is that the tutorial introduces comprehensions backwards, as though
> they are a macro for the for-loop
Python doesn't have macros as such, but if it did, that would be a good way to
describe comprehensions.
Another way would be to say that comprehensions are syntactic sugar for a
for-loop and accumulator.
You say "as though they are", but that's exactly the point -- that is precisely
what they are.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list