Change the future

Saturday 5:10 p.m.–5:40 p.m.

Dynamic Code Patterns: Extending Your Applications with Plugins

Doug Hellmann

Audience level:
Best Practices/Patterns


Python makes loading code dynamically easy, allowing you to configure and extend your application by discovering and loading extensions at runtime. This presentation will discuss the techniques for dynamic code loading used in several well-known applications and weigh the pros and cons of each approach.


Unlike many programming languages, Python makes loading arbitrary code at runtime straightforward. That means applications written in Python are easy to extend without modifying their core code directly. This presentation examines several open source applications to find patterns in the different techniques used for creating those extensions.

Example source from each application is covered, and the techniques employed are compared in three dimensions: discovering available extensions; enabling and disabling extensions; and loading extensions at runtime.

The applications studied include

  • Mercurial
  • Sphinx
  • Trac
  • virtualenvwrapper
  • Django
  • nose
  • ceilometer
  • OpenStack CLI
  • cliff