Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.

A session at Kiwi PyCon 2016


Monkey patching has come to have a reputation of being somewhat evil. In this talk you will learn what monkey patching is all about and whether its reputation as being evil is truly justified.


Python is a dynamic programming language and has a strong tradition of adhering to a programming style called duck-typing. This means that it is possible to easily modify an application's code while it is running. One might wish to do this for various reasons, including enhancing the functionality of code, correcting errant behaviour, or adding instrumentation or debugging code.

Making such code modifications can be tricky though and not done correctly can potentially interfere with the operation of the original code, through destroying introspection abilities, not honouring the duck-typing mantra or due to being applied at the wrong time.

If you do need to do monkey patching though, the 'wrapt' library is your friend, with its transparent object proxy wrappers and post import hook mechanism, it allows you to safely monkey patch code to modify its behaviour.

Come learn about the 'wrapt' library and the joys, but also the dangers, of monkey patching.

About the speaker

This person is speaking at this event.
Graham Dumpleton

C and Python developer. Interested in Apache, WSGI, Python web hosting, Python web frameworks, Docker and Platform as a Service (PaaS). bio from Twitter

Coverage of this session

Sign in to add slides, notes or videos to this session

Tell your friends!


Date Fri 9th September 2016

Short URL


Official event site


View the schedule


See something wrong?

Report an issue with this session