Timothy Baldridge writes:
> For example, this is perfectly valid Python, and something I see
> fairly often in other people's Python code:
>
> print [(x, y, x * y) for x in (0,1,2,3) for y in (0,1,2,3) if x < y]
>
> But personally I consider this sort of code unacceptable.
>
> Instead I tend to write Python code thusly:
>
> for x in (0,1,2,3):
> for y in (0,1,2,3):
> if x < y:
> print (x, y, x*y)
How about this (my preferred version):
print [(x, y, x * y)
for x in (0,1,2,3)
for y in (0,1,2,3)
if x < y]
I prefer this especially when the result is used in a computation,
rather than printed. It removes the need to initialize some variable
to an empty list and then appending to it.
Konrad.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en