Boost logo

Boost Users :

Subject: Re: [Boost-users] [python] Adding a path to sys.path
From: Thomas Berg (merlin66b_at_[hidden])
Date: 2008-10-08 17:19:49


On Wed, Oct 8, 2008 at 10:10 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
> I tried the following code below as an alternative and it still does not
> work:
>
>
> using namespace boost::python;
>
> object sys( import( "sys" ) );
> dict sysdict( sys.attr( "__dict__" ) );
> list syspath( sysdict["path"] );
> syspath.append( "C:\mypath" );
>
> I could really use some help!
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

This is one way of doing it, works for me at least:

    python::str dir = "C:/somedir";
    python::object sys = python::import("sys");
    sys.attr("path").attr("insert")(0, dir);

Thomas


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