[Tutor] newbie question on sys.path.append()

Michael Lange klappnase at freenet.de
Wed Nov 5 18:30:14 EST 2003


as the program I am working on grows, I would like to store some of the modules that are imported
in the main program file in a separate subdirectory and add the subdirectory to sys.path.
I used sys.path.append() for this at the very beginning of this file, like:

#!/usr/bin/env python
from Tkinter import *
import tkMessageBox, tkSnack, sys, os, fileinput, Tix
sys.path.append(os.path.join(sys.path[0], 'widgets'))

so I can import the modules I stored in the "widgets" subdirectory.

I am not sure now if this might cause problems, maybe there is a more proper way to import those modules.

Any help on this would be very appreciated.

Thanks in advance


More information about the Tutor mailing list