Monkey Patching

0 votes

What is monkey patching?

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

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,120 points

Related Questions In Python

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.