PyImport_ImportModule/embedding: surprising behaviors

Alex Martelli aleax at mac.com
Sat Mar 24 12:36:56 EDT 2007


Aahz <aahz at pythoncraft.com> wrote:

> In article <mailman.5359.1174435375.32031.python-list at python.org>,
> David Abrahams  <dave at boost-consulting.com> wrote:
> >
> >I was under the impression that both the current directory *and* the
> >python library directory were already, automatically, in sys.path, so
> >I'm really surprised to see this.  Am I doing something wrong, or is
> >this simply the expected behavior (and if so, where is it documented)?
> 
> IIRC (without bother to test), there has been some change in the
> definition of "current directory" -- it used to be the actual current
> directory of os.getcwd(), but since changed to the startup directory.

In 2.3 and later, at least (sorry, no 2.2 and earlier around to check),
site.py makes every directory along sys.path an absolute path at Python
startup.  This _should_ probably be documented at
<http://docs.python.org/lib/module-site.html>, but it doesn't appear to
be clearly stated there (the page only speaks of site's job of
"appending site specific paths", and not of the other jobs it also
performs, such as normalizing sys.path by turning all paths into
absolute ones and removing duplicates).


Alex



More information about the Python-list mailing list