News for hackers. Stuff that matters.
Re:Anti-Patterns in Python Programming by cuu508 on Thursday July 10, 2014 @05:31PM (#8017465)
For a concrete example, I was just recently converting a list-of-dicts into a dict-of-dicts. Here's an isolated snippet:

http://pastebin.com/8q46bK0v

To my eye, the list comprehension version is reasonable. But I like the imperative style better: it uses the most basic language features and at a glance you can tell what it does. My favourite is the dictionary comprehension version, it's the shortest but still conveys clearly what it's doing.

Re:Anti-Patterns in Python Programming by meowface on Thursday July 10, 2014 @08:51PM (#8018322)
Yeah, I prefer the dict comprehension.

I use dict comprehensions quite frequently in my own code as well.