[Edu-sig] Gearing up (Python course...)
kirby.urner at gmail.com
Sat Jul 10 10:32:37 CEST 2010
I'm gearing up to do another Python course. PSU seems
more locked down than ever BTW. I've gotta be met by an
official to hand out user logins, as these cannot be
That's not how it used to be when I taught there before.
We're going back to hand carry and paper delivery for
more sensitive information apparently, kinda retro.
I should wear something sensibly 1940s.
A primary technique is to teach enough basic syntax,
after startup and shutdown practice, to enable "doodling".
This means I get to talk about one thing, while they
multi-task, checking out arithmetic ops, range(), slice,
a few string ops, check the error messages.
Chatting about help & dir helps some, but probably
more useful is I doodle some too, projecting up front.
We cover a few bases, then they doodle while I ramble.
Maybe I talk about PEPs, go over some history, yak
about Pycons, poster sessions, user groups...
Then we cover a few more bases and repeat.
Doodle while hearing some talk about open source,
GNU, GPL, MIT, OLPC... chime in with news and views?
We'll get to Lightning Talks later (a way for students
to voluntarily share about projects).
A goal is to develop comfort with simple interactivity,
you could say "using Python as a calculator". Saving
to site-packages, importing the namespace (different
ways to import) should round out this first section.
In terms of content, things to program around, I tend
to wander into spatial geometry, but not with any
coordinates or turtles at first.
I've got this "geometry plus geography" heuristic
goin' where these are the only two subjects under
the sun (per posts to mathfuture, a Google group),
so it's easy for me to frequent this area.
Geometry is thinking (imagination) and Geography
is the real world (i.e. everything else).
I'm a big fan of "gnomon studies"  which includes
figurate and polyhedral numbers. 'The Book of
Numbers' by Conway & Guy was influential.
I've already filed hundreds of posts about this in this
archive, so probably shouldn't get too verbose.
10 * f * f + 2 is a good one to play with.
>>> [10 * f * f + 2 for f in range(11)]
[2, 12, 42, 92, 162, 252, 362, 492, 642, 812, 1002]
The initial 2 should be a 1 if you wanna match up
with Encyclopedia of Integer Sequences.
I like having polyhedra going, via figurate numbers,
because they're the paradigm "objects" or "action
figures" of the cybernetic vista.
Figurate or polygon numbers become polyhedral
numbers, i.e. we go from triangular numbers to
tetrahedral numbers pretty easily, or squares
to half-octahedra (Egyptian pyramids).
[ Actually, over on Math Forum, I've got a
curriculum guy telling me polyhedra just don't
relate to anything, that he can see, so I realize
it's sometimes an uphill battle to champion
their relevance, chemistry and biology
notwithstanding (all geography in the two-
subject framework) ]
Any "sim" or screen character may be thought of
as an animated, multi-faceted avatar, a "puppet"
of behind-the-scenes software (screen-as-theater,
one of the oldest motifs, so familiar from television).
However, aside from a few Youtubes (e.g. ), other
static web pages, I'm mostly relying on student
imaginations to provide the visuals at first. It's like
learning to read without pictures, engaging the
imagination while focusing on a purely lexical
I'm pretty adamant that programming is a more lexical
and/or algebraic activity, and whereas I'm a big fan
of right brain mental geometry, I'm concerned that
too many resources pander to an anti-lexical bias,
feeding student aversion to "straight text".
At some point, it pays to stop trying to make every
experience some kind of video game. Better to
get back to games with words themselves (more
like crossword puzzles) and cultivate an awareness
Messing with fonts may come in handy (in Portland
we have Bram Pitoyo, a total font head, frequents
the conferences). I always like to show off Akbar
font, mention The Simpsons and Matt G. (from
There's a kind of stunting or atrophy of the left brain
we need to worry about as well (cuts both ways).
That's why I want early "doodling" to be chiefly
lexical, with no immediate "turtle gratification"
(nor VPython at first, much as I love to use that
Remember, these are teenagers, not tiny children.
They likely know how to type some, and won't have
a problem spelling out words.
Having these "words" (expressions, short programs)
"laugh and play" i.e. "talk back" because of the
interpreter environment, is supposed to be a game
in itself (a kind of "language game").
It's supposed to be interesting to reverse lists (play
with palindromes), pop a stack, feed a queue or
whatever. Look up in a dict. import cos and sqrt.
>>> from math import sqrt as root2
>>> def root3(x): return pow(x, 1.0/3.0)
To uphold my reputation as an "objects first" kind
of teacher, I'm going to focus at least part of my
patter on what OO is about and why it was supposed
to be an advance.
Functional programmers voice their concerns that
OO is potentially messy, doesn't do enough to save
us from ourselves.
But the goal was to imitate "the real world" in some way
(the geographic realm). Knowledge domains naturally
fragment into "things" with behaviors (capabilities)
and attributes (properties).
OO isn't a computer thing, it's a "natural habit of
thought" thing. Here's one flavor of logic that aims
to capture "natural language" to some primitive
extent. Philosophers please take note (they
haven't been, mostly).
And it's potentially messy because the real world
is messy. The idea of objects with state, with APIs
to change state, is reflective of everyday encounters,
adventures in Geography (where even insects have
I suppose that could be read as a defense of crummy
programming, but that's not my intent.
We do need to learn about pitfalls and the difference
between beautiful code and gnarly unmaintainable
code (the latter more likely what a solo programmer
will write, and think clear as day -- why we think a
minimum of two coders per project is a serious
benefit to all concerned).
What behaviors and attributes do polyhedra have?
Their number of vertexes V, edges E and faces F
(simple counts) are good examples of attributes.
Verbs would be "scale" (grow / shrink), "translate"
(move about, accelerate) and "rotate" (symmetries,
great circles of spin, axes, cleaving into parts).
Even without doing any graphics, we might
implement a method called "dual", which appears
to transform a polyhedron into its dual (I say
"appears" because in these simple "cave
painting" examples we might just switch
the values of V and F, keeping E the same
--- one line of code basically).
Showing off Google Sketchup might be worthwhile
at this juncture, even if it's more of a Ruby thing
(we like Ruby just fine).
I introduce "dot notation" as following these patterns
(sort of): noun.verb(args); noun.adjective. I'm
influenced by J here, which although more functional
in some ways, is all about using parts of speech,
grammar, as a way of talking about the J language.
Language teachers will love computational math
all the more if it reinforces the importance of learning
parts of speech, so I figure this is a win-win when it
comes to inter-departmental relations. The DOM
relates to language arts as well. A lot of computer
topics are intrinsic to the humanities these days
(I'm playing with the idea of using this in my Martian Math class at
More information about the Edu-sig