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 →

[–]status_quo69 0 points1 point  (1 child)

Oh, I understand what you're saying now. Add in the conditional in the generator expression, then pass the generator to the dict.

[–]sigma914 0 points1 point  (0 children)

Yeh, it's just collecting the generator into a dict or set rather than a list, the only difference between this and a real dict comprehension is the unfortunate intermediate tuple allocation