PYTHONPATH and embedding python

Ken Seehof kseehof at neuralintegrator.com
Wed Oct 10 04:13:13 EDT 2001


> On Wed, 10 Oct 2001, Ignacio Vazquez-Abrams wrote:
>
> > On Tue, 9 Oct 2001, Ken Seehof wrote:
> >
> > > // untested code:
> > >   char *path, *newpath;
> > >   path=Py_GetPath();
> > >   newpath=new char[strlen(path)+4];
> > >   strcpy(newpath, path);
> > >   strcat(newpath, ":.");  // ":." for unix, or ";." for windows
> > >   PySys_SetPath(newpath);
> > >   free(newpath);
> >
> > D'oh! Yeah, that's what I meant. I guess I never noticed anything
because the
> > module I used to test it is this " big.
>
> Well, except for the new[]/free mixing of course. the call to free should
> probably be a del[] (I think that's it; I can't find my copies of EC++ and
> MEC++ right now...).
>
> --
> Ignacio Vazquez-Abrams  <ignacio at openservices.net>

Oops.  That's what happens when I post untested sample code :-)
I've happily been away from C++ for a few months.

Should be more like:

// still untested code:
  char *path, *newpath;
  path=Py_GetPath();
  newpath=new char[strlen(path)+4];
  strcpy(newpath, path);
  strcat(newpath, ":.");  // ":." for unix, or ";." for windows
  PySys_SetPath(newpath);
  delete [] newpath;






More information about the Python-list mailing list