Re:Rust for Python Programmers
by scardine on Wednesday May 27, 2015 @03:06PM
(#9613605)
Some people consider an abuse of list comprehensions if you use them just for the side effects. Why not just a plain for loop?
[ Parent
| on HN ]
Believe it or not, it's the first time I've used a list comprehension for execution like that (other than when working interactively in ipython)! Originally I had a comment about how it was a non-idiomatic thing to do, but I deleted it.
What's strange is that I didn't even consider writing the for loop on a single line. I just never do that. It's clearly better in this case (than a list comprehension). In real code I'd just do it on 2 lines.
I plead guilty your honour, the one-liner syntax for loops is pretty frowned upon among pythonistas too. :-)
It's actually a style violation: https://www.python.org/dev/peps/pep-0008/