Actually, a simpler way is just to use literalinclude to pull in each of the examples:

http://sphinx-doc.org/markup/code.html#directive-literalinclude