Monkey Patching

0 votes

What is monkey patching?

Jul 20, 2018 in Python by eatcodesleeprepeat
• 4,670 points
37 views

1 answer to this question.

0 votes

Dynamically modifying a class or module at run-time.

  1. >>> class A:

  2.   def func(self):

  3.       print("Hi")

  4. >>> def monkey(self):

  5. print "Hi, monkey"

  6. >>> m.A.func = monkey

  7. >>> a = m.A()

  8. >>> a.func()

Hi, monkey

answered Jul 20, 2018 by Priyaj
• 56,520 points

Related Questions In Python

+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 216 views