[Tutor] Noob: nested if-clauses

Alan Gauld alan.gauld at btinternet.com
Fri Jan 29 20:06:51 EST 2016


On 29/01/16 17:41, STF wrote:

> what that gives.  IDLE is indeed easier to use than the "DOS-style" Python
> command-line window.  

One thing I'd say is that you can tweak the DOS CMD window quite
a lot to make it better for IDLE(and other interpreters). But
IDLE is probably still better for most folks.

> How do you call this thing, BTW?  I'm unable to
> understand how to navigate inside this thing.  

I'm not totally clear what you mean here.
You start IDLE from the start menu or desktop shortcut.
That gets you to the interactive shell which is a version
of the python interpreter running inside idle

> I mean, when I open it, in which folder am I in?

You can find out with

>>> import os
>>> print ( os.getcwd() )

But its rarely important because you normally use
File->Open to open a file, or File->New to create a new
one and save it wherever you want).

Once you do that IDLE opens a new editor (as opposed
to shell) window. From there you can use the Run menu
to execute your code with the output appearing in the
original shell window.

> Suppose I have a Python file in
> D:\mycode\abc\myfile.py.  How to run it?

Within IDLE use File->Open to locate and load it.
Then use the Run->Riun Module menu command (shortcut F5)

Outside idle use

C:\SOME\PATH> python D:\mycode\abc\myfile.py

You can of course create a shortcut to do that.

or CD to the folder:

C:\SOME\PATH> CD  D:\mycode\abc
D:
D:\mycode\abc>

then type

D:\mycode\abc> python myfile.py

hth
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list