Pyknon
Pyknon is a simple music library for Python hackers. With Pyknon you can generate Midi files quickly and reason about musical proprieties. It works with Python 2.7 and 3.2. It's a library intended for teaching and demonstrating, so you should have no problems reading the source code.
https://kroger.github.io/pyknon/