Python and Schools

Alex Martelli aleax at
Tue Apr 15 14:08:39 CEST 2003

Aahz wrote:

> In article <v9e21mhemm8c2 at>,
> Paul Watson <pwatson at> wrote:
>>We need to teach students correct design priciples to build something
>>greater than what already exists.  We will never get very far if we
>>require everyone to start with a quark or atom.  Yes, of course we need
>>some people who design silicon and create microcode.  They will learn
>>the low-level details what they need to know as they need it.  Knowing
>>great design and organization principles will enable them to make the
>>most of it.
> While there's some truth to that, try explaining why the following code
> is a Bad Idea to someone who has no basic understanding of CS:
>     s = ''
>     for i in range(1000000):
>         s += str(i)

I will gladly accept the challenge, if we can agree on the details to
determine whether I've won or lost the bet.  What I require is somebody
with real, earnest *interest* in *understanding* this stuff -- I'll
gladly undertake to supply all necessary *background*, but I have no
idea on how to awake real interest in somebody whose motivation for
learning is just "serving time" or some vague hope of getting a good
paying job (and that would be just as much of a problem, whether the
subject was "CS", "programming", or "artichoke farming techniques").

If the interest is there, and enough Python background to understand
exactly what this program snippet DOES, then in about one or two
hours of face to face instruction I can give a model that will allow
the student to predict this snippet's disastrous performance and
compare it to the expected performance for, e.g.,

    s = ''.join([str(i) for in in range(1000000)])

It's not rocket science (that's _another_ thread...;-) -- at this
level, it's really simple arithmetic, a decent mental model of "an
abstract underlying machine", AND an interest in understanding this.

> Knowing the difference between O(N) and O(N^2) is critical to writing
> even the simplest programs.  OTOH, I do agree with you that focusing on
> programming as a craft is more important to being a programmer than
> learning CS.

I'm not dissing CS (though I could well have some fun dissing it on
some other thread...!-), I'm claiming that one can become a rather
effective programmer in Python with only those modest, approximate CS
concepts that it's feasible to explain within a first programming
course (to _interested_ students...).  For example, while we keep
mentioning big-O ("worst-case"...), what we're really USING most of
the time is really big-Theta ("_typical_ case", _expected_ performance).
Except in hard real-time programming, hardly anybody ever does more
sophisticated analysis than "_expected_ performance" during the design
of actual programs...


More information about the Python-list mailing list