Monkey-patching a Python instance method

Dynamically adding or overwriting an instance method in Python is rarely needed, but it’s a good excuse to explore interesting aspects of the language that aren’t always well known: the descriptor protocol, types.MethodType and partial function applicatio…

Similar

Python Gotchas

For the most part, Python aims to be a clean and consistent language that avoids surprises. However, there are a few cases that can be confusing for newcomers. (more…)

Read more »