3 ms·
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
by agumonkey 3y 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)
- conkeisterdoor 3y agoI also strongly prefer the dictionary comprehension and find it much more readable - for whatever my 2c is worth.
- agumonkey 3y agoto 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