[Edu-sig] Python for Wanderers (Class 2)

kirby urner kirby.urner at gmail.com
Fri May 11 17:15:43 CEST 2007

I'm numbering from 0, Python style, so this was actually our third meeting
in the boyhood home of 2x Nobel laureate Linus Pauling, sitting around
the big table, with projector (Optoma), speakers (including woofer), and
laptop (Toshiba Satellite, WinXP w/ Python 2.5, VPython, POV-Ray 3.6,
wxPython and PythonCard).

The course for adults parallels my Saturday Academy course to some
degree and I again showed Code Guardian as an opening cartoon feature,
to show what one guy and some friends could now accomplish with a
rendering engine, given sufficient talent, skills and commitment (can't
trivialize any of those, if the end result is great art, which Code Guardian
certainly is (cee-gee.net)).

By way of intro on the whiteboard (erasable colored pens), I drew three
partially overlapping circles, Venn Diagram style (each overlapping
the others, a place in the center where they all overlappped).  In the
circles I wrote M, V, C for Model, View, Controller.

I quickly connected MVC to a history of programming we'd already
(i)  wild west spaghetti code era, deriving from hard wiring
(ii)  compiled imperative languages (COBOL, Hopper)
(iii) structured programming (Djikstra),
(iv) then more sophisiticated paradigms, including OO and then DP,
where DP = design patterns, let's say premised on OOP, and where
MVC is one very common design pattern people talk about.

In this class, M, our model, depends mostly on the XYZ Cartesian
style math kids already learn as a part of middle and high school,
i.e. the usual pre-college analytical geometry pioneered by Descartes,
Fermat and folks like that, already very entrenched, and later,
via Hamilton, Gibbs, Heaviside and others, becoming today's
"vector algebra" from whence the term "vector graphics" is derived.

So for a Model, we're using high school analytic geometry and
vector algebra.  Good way to lean both, with Python mediating.
Start with Dog and Monkey as subclasses of Mammal, to get
familiar with a few __rib__ special names, the whole idea of
classes, subclasses and objects, then move to "math objects"
(more abstract) such as Vector, Edge and Polyhedron.

V, our view, comes in two basic flavors:

(A) real time and
(B) render time.

In real time, you get such as OpenGL, with a simplifying VPython
facade, and/or DirectX or whatever.  Engines that respond in real
time to give a game-like experience (or a game).  Doom by id set
the standard when PCs were still new, showing what intelligent
coding could accomplish, in terms of a first person shooter,
with the minimal hardware of the day.  The games have only
gotten more impressive since then.

And yet when it comes to attention to small detail and photo-
realism, the real time games still can't reach the level of a rendered
movie, like 'Shrek' or 'Cars' or 'Over the Hedge'.  That's because in
render time we have all the time we need to trace every ray of
light, to get those photo-realistic frames, which only at the end
get strung together and projected at a real time frame rate.

So this counts as our other broad category of View -- not like
these are the only two, plus many times we interleave them,
i.e. a real time game will suddenly switch to a canned loop
developed with ray tracing.

To give students "cave painting" [1] insight into both kinds
of view, we use Python as our controller (C).  Python talking
to VPython represents real time animation and simulation,
ala the game engines, whereas Python talking to POV-Ray
represents render time animation ala the movies, movies
like Code Guardian.

Python also implements a lot of the Model, in that the polyhedra
and vector algebra we need is all exposed in source code, in
the form of stickworks.py and polyhedra.py.  There's a minimal
Vector class, wrapped around VPython's, which we actually
keep using when writing Scene Description Language for
POV-Ray -- because in terms of the model, a vector is a vector
and all we need is to be able to add and scale them (__add__
and __mul__ them).

In sum, I'm seeing these major themes emerge from this course,
which I'm regarding as open source and transferrable, usable
by other teachers and/or peers teaching peers (which explains
the screencasts):

(1)  history of computer programming, emergence of OO and DP
(2) MVC as a DP example, with broad categories of V being
    (a) real time (games, some simulations, musc visualizers,
        screen savers)
    (b) render time (cartoons, some simulations, Animusic,
        photo-realistic static screen savers)
(3) Python is implementation language
(4) Vector graphics and analytic geometry for controlling the model
(5) Python playing well with others, gluing together different kinds
of engine (in this case OpenGL and POV-Ray).

All of the above I think proves quite an eye opener for middle and
high schoolers, not only in terms of reinforcing their everyday
math and giving them entre to a powerful programming language,
but in terms of giving a "how things work" overview of a lot of
state of the art technology.

Other courses will showcase different aspects of course.  Like
in my course for Winterhaven (Portland Public), we focused
on XML (xml_rpc), GIS (Google Earth), and even a little on
MySQL (my geographic quiz showcases USA states and
capitals, very traditional, but with this Pythonic layer between
a database and the web, ala LAMP) [2].


[1] "cave painting" means "enough of a semblance to give
the idea but minus much detail" (say "dumbing down" if
you like but I prefer "homomorphism" (vs. an "isomorphism"))
i.e. an analogy with many dimensions missing by design).
Example usage:

[2] http://mail.python.org/pipermail/edu-sig/2005-November/005533.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/edu-sig/attachments/20070511/8900548a/attachment.htm 

More information about the Edu-sig mailing list