Sep 18, 2022
I had forgotten about dict.fromkeys
, but now we have dict comprehensions, it has really lost its use, in the same way that map
, filter
and reduce
have.
Just use {k: 0 for k in d}
which is also less typing.
Don’t get me wrong, this was also a lesser-known feature in Python. This article was definitely as advertised, and a lot of fun. Have claps!