Overall, this is a nice post. There are two quibbles though.
1). For the most part, "c = collections.Counter()" is almost always better than "c = defaultdict(int)"
* Counter only supplies missing values rather than automatically inserting them upon lookup.
* The Counter version is much clearer about what it is trying to do. The defaultdict version is cryptic to the uninitiated (understanding it entails knowing that it has a __missing__ method to insert values computed by a factory function and that int() with no arguments returns zero).
* The Counter version provides helpful methods such as "most_common(n)".
2). An ellipsis in Python is normally used in a much different way than shown in the article (it's used for an extended slice notation in NumPy).
1). For the most part, "c = collections.Counter()" is almost always better than "c = defaultdict(int)"
* Counter only supplies missing values rather than automatically inserting them upon lookup.
* The Counter version is much clearer about what it is trying to do. The defaultdict version is cryptic to the uninitiated (understanding it entails knowing that it has a __missing__ method to insert values computed by a factory function and that int() with no arguments returns zero).
* The Counter version provides helpful methods such as "most_common(n)".
2). An ellipsis in Python is normally used in a much different way than shown in the article (it's used for an extended slice notation in NumPy).