Q40: What is Monkey Patching and what are its risks?
Monkey Patching refers to dynamic runtime modifications of classes or modules at application startup (e.g. overriding methods or libraries on the fly). Common in testing mocks or event loop patching (gevent), but risks introducing hard-to-debug runtime side-effects.
Key Takeaways
- Dynamically mutates module/class attributes at runtime.
- Useful for testing mocks, but risky in production systems.
Knowledge Check
When does monkey patching modify the target class behavior?