[Tutor] Learning programming

Hans Nowak ivnowa@hvision.nl
Sat, 3 Apr 1999 18:54:01 +0100


On 3 Apr 99, Ce'Nedra took her magical amulet and heard John Kleinjans say:

>figured this out:
>
>1) get a windowing environment running

Why? That's not necessary... Python for Windows is pretty good, but there are 
other versions around working in "console-mode".

>2) get Python running in one window
>3) get a text editor running in another window
>4) with the text editor, write your program (call me "prog")
>5) save your program to disk 
>    a) in the Python directory
>    b) with a ".py" extension
>6) switch to the Python window and
>>>> import prog

In my opinion, the best way to start a Python program is still from the 
command line, possibly specifying options and arguments for your program. So

python myprog.py

should do, too.

It seems that you are used to a DOS environment. If this is the case, then I 
would suggest installing 4DOS which makes starting a program easier. I start 
my program by just typing the program name, like

myprog

like it was an executable. Also, an editor with some macro capabilities is 
also useful. I use vim 5.x myself, but there are lots of editors around (I 
don't recommend vi for newbies :^). With 4DOS and the editor combined, I edit 
my program, save it by pressing F2, and run it by pressing F9 (or Shift-F9 if 
I want to specify arguments first). Instant IDE for DOS or Win95 console 
mode.

And this is just one way to do it. Python 1.5.2 comes with a development 
environment called IDLE, to name something. There's PythonWin...

>7) at his point,
>    a) your program might actually run
>    b) you'll probably get some error messages
>8) switch back to the editor window
>9) edit the program. Try to fix it.
>10) SAVE IT TO DISK AGAIN
>11) switch back to Python and type
>>>> reload(prog)
>
>-----
>
>At this point, 7 through 11 keep repeating. 
>
>Beginning programmers would take a very long time to figure this out.
>They'd probably quit first. 

I see your point. Although some of the points you mention (like the saving 
and editing thing) is considered common knowledge unless you're an absolute 
beginner, also when it comes to computers. Even my mom who just started with 
Word knows that she should save regularly. :^)

>Please tell me; am I doing this the hard way? Or is this the way? 

There are easier ways...

>We should probably provide more detailed instructions for users of DOS,
>Macs, even Windows. Realistically, that's what's running on most boxes out
>there... there's a lot of kids with W95 (or even W311, or DOS) boxes who
>would like to learn how to program. 

I don't disagree, although this is a mix of 'how to start programming' and 
'how to start with computers'. If someone doesn't know about editing and 
saving yet and about the operating system in general, I don't know if it's 
such a good idea to start programming already. ;^)

>I teach high school--that'll probably (assuredly) affect what I see and
>say. That's not so bad. And I teach programming (and some other things). 
>
>Well, I'd like to see if this effort gets from here to there (and back
>again) before I put more into it. 

I can understand that. Python is not something that comes in a box with 
disks/CDs and a coupla manuals to get you started. Still, working with it 
isn't too hard, it's just a bit different from commercial environments like 
Delphi, VB or (some years ago) Turbo Pascal. (I must admit that when I 
started with Python, this bit me too. Heck, I even hacked the Turbo Pascal 
editor so it accepted .py files and started them upon pressing F9...)

Regardz,

+  Hans Nowak  (Zephyr Falcon)
+  Homepage (under construction): http://www.cuci.nl/~hnowak/
+  You call me a masterless man. You are wrong. I am my own master.
+  May Duke Nukem pull the plug out of your nail polish!