Importing from Another Path

Peter Mayne Peter.Mayne at au1.ibm.com
Fri Jul 27 06:32:20 EDT 2001


> Ype Kingma wrote:
>
> > > sys.path.append("..\\common")
>
> Actually I just meant that it wasn't portable between Windows and Linux
> because I'm using backslashes in the path.

Windows is perfectly happy to accept "/" in a filename path. Try

sys.path.append('../common')

However, this won't help when someone runs the script on an OS that doesn't
accept either form.

> This works, but a) I don't need sys so importing it seems like a waste,

Why not just

from sys import path
path.append('../common')

?

PJDM
--
Peter Mayne
IBM GSA (but the opinions are mine)
Canberra, ACT, Australia
This post is covered by Sturgeon's Law.





More information about the Python-list mailing list