[Tutor] How to run a script file
Alan Gauld
alan.gauld at freenet.co.uk
Wed Jan 5 08:33:54 CET 2005
> Then I add my custom path to the sys.path list (because my user
> permissions do not allow my to put anything in the Lib directory)
and
YOu should be able to create a personal startup script in your
homedir.
I've not done it but I'm sure I remember reading about it, and its
pretty standard LInux practice.
> then I try an
> import /home/bernardl/python/myScript.py
> but of course if fails as soon the first slash is read.
If you've added the path to sys.path you should only need to do
import myScript
no .py and no path.
Remember that import does NOT import a file it imports a module
object (which just happens to correspond to a file with a similar
name!)
HTH
Alan G.
More information about the Tutor
mailing list