Running a set of Python scripts in a list
<p>I am working on a Python project that includes a lot of simple example scripts to help new users get used to the system.  As well as the source code for each example, I include the output I get on my test machine so users know what to expect when all goes well.</p>

<p>It occured to me that I could use this as a crude form of unit testing.  Automatically run all the example scripts and do a load of diffs against the expected output.</p>

<p>All of my example scripts end with extension .py so I can get their filenames easily enough with something like</p>

<pre><code>pythonfiles=[filename for filename in os.listdir(source_directory) if filename[-3:]=='.py']
</code></pre>

<p>So, pythonfiles contains something like ['example1.py', 'cool_example.py'] and so on.</p>

<p>What syntax can I use to actually run the scripts referenced in this list?</p>
