[Tutor] "hello, python world!"

Alan Gauld alan.gauld at blueyonder.co.uk
Sat Mar 20 13:54:02 EST 2004


Hello and welcome.

> i downloaded the python 2.3 installer and did a quick install.

Well done, that's the first step.

> I took a quick look at IDLE 1.0 (guess they have not updated this
> program)

Actually IDLE has been progressing for quite a while, it only
reached 1.0 with Python 2.2 I think... In the early Python
releases IDLE didn't even exist!

> Q. On my first night trying to learn Python 2.3, I noticed
> when I click on the program it opens a window that lookes
> like DOS,

It is DOS. Or more accurately its a Windows Command prompt.

> is this because Python for Windows is based on python
> for DOS?

Nope. There is only one Python (actually not strictly true
but for the purposes of this discussin it is!). The same basic
Python program works on DOS, Windows, Linux and Macintosh.
They all bring up a command line prompt if you type (or click)
python without passing a file to it.

> Q. Can python change the input or raw_input window to the
> size of a message box with color? (pixels, percent ect.)

No, but it can be used to program GUIs which have those
features. However the simplest commands (print, raw_input)
use the command prompt (aka DOS box). Thats one reason for
IDLE, to provide a more Windows like environment.

> Q. I had a hard time figuring out how to do the password.py
> in the tutorial Josh Cogliati made.

So does everyone it seems! :-)
But at least you made it, so thats excellent!

> then i typed the program in Notepad and opened it with IDLE
> (now i find you can just open new window!)  Is Notepad
> suitable for programming on Windows XP?

As you've seen it can be done but IDLE is much better.
Regular programmers all have their favourite text editor
and can argue for hours over which is best, but if you
are not allready addicted to one particular brand
- and it sounds like you might be a complete beginner
to programming not just Python? - you might like to try
downloading Scite. Its an excellent alternative to IDLE,
at least then you have a choice. But before doing that
go to Danny Yoo's IDLE tutorial and run through that.
You might well decide to stick with IDLE.

> Q. Can I attach files, example code, print out of errors
incountered?

Attach files if they aren't too long(not thousands of lines!).
Example code is usually best. Error printouts definitely,
with a few lines of code to provide the context if possible too.

> Q. Since indentation is very important where can i go to
> find the rules in a way a non-programmer can understand

The rules are really simple. Just be consistent in how much and
never mix tabs and spaces. (In fact I strongly recommend to just
use spaces!)

In practice most folks find you need at least 2 spaces to be
effective and more than 4 or 5 becomes very spread out.

The whole concept of indenting code is so that you get a visual
clue as to the structure of the program. All the related lines
are grouped together by the indentation. If you keep those
ideas in mind indentatuon will quickly become intuitive.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list