Computational Modelling Group

Workshop  28th April 2016 3 p.m.  B177, 2023 (NGCM Common Room)

Workshop: Metaprogramming in Python

Lucy Upton
CDT in Next Generation Computational Modelling

Web page
https://github.com/physicslucy/metaprogramming
Categories
IPython/Jupyter Notebook, NGCM, Python, VirtualBox
Submitter
Lucy Upton

Metaprogramming

Metaprogramming is the process of writing code which manipulates existing code, such as functions or classes. It is a simple technique which can eliminate code repetition without introducing inheritance classes or multiple similar functions.

The Workshop

The workshop will be taught by Lucy Upton, a first year PhD student from the Next Generation Computational Modelling (NGCM) CDT. It will be taught through iPython notebook, and will consist of a short talk, live-demonstrations and exercises in Python.

The aim of this workshop is to introduce the concept of metaprogramming and to explain why and when to use it. You will learn to write and implement wrappers and decorators for both function and classes. By the end of the session, you should be confident to go forth and use metaprogramming in your code.

Prerequisites

This workshop will require familiarity with programming in Python.

All are welcome, please bring a laptop with either Python and Jupyter or VirtualBox installed to be able to take part in the exercises.

Install Python and Jupyter

Comprehensive instructions can be found at:

http://jupyter.readthedocs.org/en/latest/install.html#new-to-python-and-jupyter

or Download the Virtual Machine

If you do not wish to download Python and Jupyter, but you have VirtualBox or can download VirtualBox, please download the virtual machine for this session. This can be found at:

www.soton.ac.uk/~ngcmbits/virtualmachines.

The documents used in this session can be found at

https://github.com/physicslucy/metaprogramming.