What is monkey patching in python? Flashcards

(2 cards)

1
Q

general summary

A

Monkey Patching involves dynamically modifying or extending classes or modules at runtime. While being a handy tool, it’s often best used with caution as it can lead to unexpected behavior and code maintenance challenges.

Monkey Patching is typically used in Python when you can’t (or shouldn’t) change the class or module’s source code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

common use-cases

A

Fixing Bugs in External Libraries: It can be used to temporarily fix an issue until an official fix is released.

Testing: Allows for quick and easy stubbing or mocking in unit tests before official classes or modules are available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly