
17 Jun
2009
17 Jun
'09
7:14 p.m.
I'm running a bunch of python scripts from a directory, one after the
other.
I want to make sure that those scripts don't interfere with each other.
My code looks like this:
for(directory_iterator itr(filterDir);itr!=directory_iterator();++itr) {
if(itr->path().extension()==".py") {
try {
object global = import("__main__").attr("__dict__");
object sys = import("sys");
sys.attr("path").attr("append")(str(filterDir));
exec_file(str(itr->path().string()), global, global);
} catch(error_already_set const &) {
cout<<"Python syntax/runtime error."<