logoalt Hacker News

kristianp • yesterday at 11:51 PM • 1 reply • view on HN

Interesting difference between Go and Python, `c.counts[name] += n` can allocate if name isn't already present, whereas in Python you get a key error.


Replies

NewJazz • today at 6:21 AM

Isn't that mainly because Go has a somewhat insane behavior of default values?

Also I'm fairly sure you can accomplish the same thing in python with a defaultdict.