Boost logo

Boost Users :

Subject: [Boost-users] python context scope question
From: Christopher Harvey (chris_at_[hidden])
Date: 2009-06-17 15:14:51


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."<<endl;
      PyErr_Print();
    } catch(...) {
      cout<<"Uknown error from script file: "<<itr->path()<<endl;
    }
      }
    }

Basically what I want to know is this:
For every iteration of the exterior for loop will any of the scripts
that are executed be able to impact in any way another script that is
executed?
For example, I was thinking a script could remove that path that I want
to add from the import search paths and break the next script that is
run, since it wouldn't have that path.

thanks.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net