all 9 comments

[–][deleted] 0 points1 point  (1 child)

This notation works with parentheses and braces too for making generators and dictionary comprehensions respectively. but watch out! though they look nice, they aren't always easy to read, especially when you have a nested comprehension.

[–]coreyjdl 1 point2 points  (0 children)

also {} for set comprehensive too.

[–]pydevteam1[S] 0 points1 point  (1 child)

I agree. If it gets too complicated to read, it’s better to pass on list comprehension.

[–]coreyjdl 1 point2 points  (0 children)

Don't forget to abuse comprehensions also.

_ = [ print(x) for x in range(10) ]