Reading List
Python tip: default when fetching a dictionary key value. from Ru Singh RSS feed.
Python tip: default when fetching a dictionary key value.
Today I Learned that when fetching a value from a Python dictionary, you can set a default! A trivial example: That’s pretty neat! Seems like some other dict methods have this signature too. Ivan Sagalaev adds: You can also take out that key and value from the dict if you’re using .pop() instead of .get(). For example, it’s often useful ... Continue reading →