[Pythonmac-SIG] newbie file path question
Richard Gordon
richard@richardgordon.net
Sun, 15 Jul 2001 18:16:37 -0400
At 3:21 PM -0500 7/15/01, Scott Griffitts wrote:
>How do I import a .py file outside of the Python directory?
>
>for example, if I want to import test1.py from the following path:
>
>HD:folder1:folder2:folder3:test.py
>
>how do I word the file path between import and test.py?
Aside from Just's suggestion that you edit your preferences to
include the desired path, you could temporarily append it to sys.path
as follows:
import sys
sys.path.append('HD:folder1:folder2:folder3')
import test1
Note that a trailing ":" is not necessary if you are going to do it
this way and you do not include the .py extension in an import
statement in any case.
Richard Gordon
--------------------
Gordon Design
Web Design/Database Development
http://www.richardgordon.net