Comment by agumonkey
2 years ago
good point but it's culture dependent
i had people telling me
d = {i:str(i) for i in range(10)}
was too hard to read, preferring
d = {}
for i in range(10):
d[i] = str(i)
2 years ago
good point but it's culture dependent
i had people telling me
d = {i:str(i) for i in range(10)}
was too hard to read, preferring
d = {}
for i in range(10):
d[i] = str(i)
I also strongly prefer the dictionary comprehension and find it much more readable - for whatever my 2c is worth.
to me it's even beyond readability, it's a close oneliner scope.. less opportunity to insert some weird statement / bug in it
but anyway, to some senior engineer, the dict comprehension is a chore