[Tutor] Help this newbie
alan.gauld at btinternet.com
Fri Mar 21 09:24:38 CET 2008
"Elliot Silvers" <esilvers68 at hotmail.com> wrote
> I am as new as you can get to Python. I have just learned
> how to save my work (very simple work of course).
> I created a folder on C:\ (in this case C:\Elliot) for my work.
> I am able to use the cmd prompt to run it
Congratulations. You should also be able to run it by
double clicking in explorer.
> however I cannot figure out how to import it using the
> python (command line).
Can you show us what happens when you try.
Cut n paste from the command window into your email.
However there are two areas which might be messing things up:
1) do not specify the .py when importing
ie to import foo.py type import foo
2) Make sure your Elliot folder is in the import path.
There are several waays to do this, the simplest is to add
your folder to the PYTHONPATH environment variable.
(If 2 is the problem then the impoprt should work OK if
you CD to your folder before starting Python...)
To set environment variables see the sidebar in the
Moresequences topic in my tutorial... You will probably
need to create PYTHONPATH as a new variable.
Author of the Learn to Program web site
More information about the Tutor