[Tutor] Help Noob Question

Alan Gauld alan.gauld at btinternet.com
Thu Mar 27 20:56:40 CET 2014


On 27/03/14 06:43, Leo Nardo wrote:
> Im on windows 8 and i need to open a file called string1.py that is on
> my desktop,

Thats your first problem. Its usually a bad idea to store your python 
code on the desktop, because the desktop is a pain to find from a 
command line.

Instead create a folder at the top level of a disk - if you have
a D drive then D:\PythonProjects or some such name.

Move your file into that folder

Then you can start a CMD shell window by hitting Windows-R
and typing cmd into the dialog that opens.
That should open a CMD shell(aka DOS box) with a prompt like:

C:\WINDOWS>

or similar

At that prompt type

python D:\PythonProjects\string1.py

And your file should run, display any output (or errors)
and stop.

> error message when i type in""" python string1.py""""" into the
> interpreter!

You never type 'python' into the Python interpreter.
You run python propgrams by typing 'python progmname.py' into your 
Operating system shell(CMD.exe on windows)

You can also run them by double clicking the file in Windows
explorer but that often results in a DOS box opening, the code
running and the DOS box closing again too fast for you to see
anything. So opening the DOS box in advance as described
above is usually better.

Get used to using the OS command line, programmers tend
to use it a lot. (In fact you might want to create a
shortcut on your desktop/start screen to open it...)  :-)


HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list