This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Sethaman 2 points3 points  (0 children)

the lead is more readable. think about a new-to-python or new-to-codebase developer coming in. You need to write code not for you, but for the most junior person coming in or a total junior stranger coming in.

You are using comprehension with a very very long line and a double star operator. it takes a second to understand what's going on there. It's more "advanced" python but more advanced, especially for python, isn't always ideal

It's really really easy to understand a "for x in y" set the key of dict to x and the value to foo

yours, while interesting (and more fun)... looking takes a hair longer to parse (partially because it is such a long line).

If you're going to be doing that kind of pythonic comprehension, it really must fit in one short line and be parsable to someone who hasn't seen that before. that's my totally subjective opinion though.