Why Type Hinting Sucks!
Type hints are great! But I was [playing Devil's advocate](https://www.reddit.com/r/Python/comments/10vh1v5/mypy_10_released/j7igi8q/?context=3)...
Stay updated with breaking news from Duck Typing. Get real-time updates on events, politics, business, and more. Visit us for reliable news and exclusive interviews.
Type hints are great! But I was [playing Devil's advocate](https://www.reddit.com/r/Python/comments/10vh1v5/mypy_10_released/j7igi8q/?context=3)...
15 Apr 2021 | 3 min read You have heard about Type Erasure of C++. You probably know std::function is a classic usage of the pattern. But what is Type Erasure in C++? It's effectively trying to achieve Duck Typing, which is common in languages like Python. # Notice that there's no relationship between Bar1 or Bar2 class Bar1: def doSomething(): print("bar1") class Bar2: def doSomething(): print("bar2") def foo(bar): # works on _any_ bar that has `doSomething()` defined bar.doSomething() # you can do things like foo(Bar1()) foo(Bar2()) for x in [Bar1(), Bar2()]: foo(x) So we...