Programming intro book ch1 and ch2 (Windows/Python 3) - Request For Comments

Alf P. Steinbach alfps at start.no
Fri Dec 18 13:00:48 EST 2009


I finally finished (draft), I believe!, chapter 2...

Chapter 1 gets the reader up & running, i.e. it's "Hello, world!", basic tool 
usage, without discussing anything about programming really. One reaction to 
this chapter, based on the two example programs in it, was that it wasn't 
gradual and slow enough; hey, those examples are far too advanced, and 
unexplained! But that reader misunderstood: the progression is actually *slower* 
than one might expect. This chapter is only about tool usage. I.e., it's about 
getting those programs running, for the reader who can't rely on teachers or 
fellow students or, as Kernighan & Ritchie put it, "your local guru" (IIRC).

Chapter 2 is about Basic Concepts (of programming). It's the usual: variables, 
basic types and arrays, loops, decision, routines, classes, events, although not 
presented in that order. I make heavy use of complete, concrete examples, many 
of them graphical, and everything is in support of what's actually needed for 
such concrete examples. The intent is to enable the reader to experiment and try 
things out  --  since the only way to really learn is by doing! As best I could 
I've labored to apply this minimalism also to the Python language, using only a 
"minimal" subset (to the degree of not even introducing boolean ops :-) ).

Chapter 3 will, by my current plan, delve into the Python language and such 
things as how integers and floating point works on the inside, and that includes 
those in chapter 2 not even mentioned boolean operations. One important issue, 
introducing exceptions, and in support of that, type hierarchies. After chapter 
3 I have only much vaguer notions about what to introduce in what order, but a 
main issue, assuming that I go on with this writing, will be to apply and teach 
methodology all the way, integrated into the examples and text.

A table of contents + chapters 1 and 2 is available in PDF format at Google Docs, at

   <url: http://tinyurl.com/programmingbookP3>

Comments are very welcome!

Re comments: there are two deviations from current Python practice in chapter 2. 
First, that I use spaces inside argument parentheses, which makes the code more 
readable when one gets used/trained to it because it gives the eye more direct 
information (with some training visual structure can be processed unconsciously 
& effortlessly, but purely logical structure has to be processed analytically). 
The second deviation is that since most names are constants, I do not follow PEP 
8's recommendation to use uppercase names of constants. In fact almost no Python 
code does, but then it seems that people are not aware of how many of their 
names are constants and think that they're uppercasing constants when in fact 
they're not. E.g. routine arguments and in particular routine names are usually 
constants, absolutely not meant to be modified, but it would be silly to UC...

So both these two deviations from Python practice are /intentional/, since this 
is a book about programming, not about Python the language & how to conform to 
idiosyncratic language-specific conventions.

But, if there are other deviations from Python practice I'd be very glad to hear 
of it! I'm very hopeful that any such convention deviations can be fixed. :-)


Cheers,

- Alf



More information about the Python-list mailing list