[Edu-sig] python satacad: class 1 (overview)
urnerk at qwest.net
Sun Jan 9 19:21:46 CET 2005
OK, the first class went pretty well I thought. I have seven students, 9th
and 10th graders (at least one is home schooled). None of them know each
other, to start, nor have I ever met any of them. We're all strangers.
When they walk in, sometimes with a parent (parents don't get to stay
though), they see a projected picture of a personal computer of 2004 -- as
envisioned by some guy at the RAND corporation in 1954.
Here's the picture (from Popular Mechanics):
(I once told mom in an email that this might be Rumsfeld's problem -- he's
still living in a past version of the future). If using FireFox, click the
magnifying glass to get full size (easier to read the caption).
The projector was always on during the class. At one point I did a lot of
fumbling to get my Linux laptop hooked up, as the instructor's Win2000 box
doesn't have a DVD player and I wanted to show some opening takes from
I emphasized to this class that Greater Portland (our land) is a kind of
Mecca in the open source community (hey, Linus himself lives here), whereas
Greater Seattle is more of a Vatican for the closed source community (Bill
Gates and his minions). This was a subtle allusion to 'The Cathedral and
the Bazaar' of course, which I don't expect anyone got (Eric Raymond was in
two video clips I showed, but I doubt many made the connection there,
We watched 'Warriors of the Net' in its entirety. A lot of these students
indicated on the reg forms that they were wanting to learn more about
computers. In the old days, that'd mean starting with the CPU, bus,
peripherals, talking about registers, RAM, BIOS. All that is still
important, but it makes just as much sense to start with TCP/IP (which is
what 'Warriors' is about).
During the Python segments, we used IDLE. I have this rap about how, in
traditional math, we don't think of numbers as knowing anything. We add 2
and 2 to get 4, but the number 2 is just a dumb number, and doesn't know
diddly about adding. But in the object oriented world, things are a little
different. I made the analogy to the movie 'The Incredibles.' The kids
inherit super powers from the parents, and just need to look within to
discover and develop them. Likewise...
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__',
'__delattr__', '__div__', '__divmod__', '__doc__', '__float__',
'__floordiv__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__',
'__init__', '__int__', '__invert__', '__long__', '__lshift__', '__mod__',
'__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__',
'__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__',
'__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__',
'__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__',
'__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__',
"Wow!" said one student. Like, we've asked '1' it to spill its guts about
what it knows and it obviously knows quite a bit! And it knows all this
because it inherits from type 'int', the type of 1:
Then I had each type their own name, with single quotes, and get the string
to spill its guts about what any string type object already knows, right
from the get go:
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__',
'__ge__', '__getattribute__', '__getitem__', '__getnewargs__',
'__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__',
'__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__',
'__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith',
'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower',
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',
'replace', 'rfind', 'rindex', 'rjust', 'rstrip', 'split', 'splitlines',
'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
I talked a lot about dot notation. We did 'import math' and math.pi and
math.sqrt(n) -- stuff like that. There's a strong metaphor of
containership. net.4dsolutions.satacad.sa6299. The 'net' domain, being
top-level, is huge. Inside it, we find 4dsolutions, and inside that, other
stuff. Likewise, with the math module: inside it, we find pi and sqrt.
So then I relate this back to integer and string objects and encouraged them
to paw through the raw dump of a string's capabilities for fun methods. I
demonstrated up front:
and like that. Similar experiments with objects of type integer. Some
initial discussion of the list type (much more next time).
Then I went through my examples of open and closed source programs. Both
play scissors, paper, rock (I had them eyeball commented code, just to get a
quick feel for what more fluent Python looks like, quick rap on flow and
control structures, Python's use of indentation in place of curly braces).
However, in this example, the closed source version randomly cheats about a
3rd of the time, and so always wins in the long run.
I'm skipping over some of the other stuff I talked about. They heard a lot
about Bob, Alice and Eve -- a sort of Garden of Eden story for
cryptographers. Next week we'll do Euclid's Algorithm for the gcd, as we
start building towards and intuitive understanding of RSA. I did go over
the phi concept (number of totatives of an integer) and showed them the
program for it in J, just so they could gawk at how different it looks (like
something straight from the worlds in Myst or Uru):
At the end, I handed out a page of URLs for optional followup (e.g. to the
edu-sig page, also to porpig.org, currently unexciting but in Plone at
least, which product I plugged, along with Zope -- also bittorrent).
Signing up for Yahoo is not something any seemed familiar with, so probably
will require parental approval/involvement. I emphasized that my Yahoo
egroup for this course is entirely optional and they're under no pressure to
join it -- just a resource I've decided to make available. I'm going to see
how it goes as a closed list for awhile, before I decide whether to open it
to subscribers from edu-sig. They know I manage the edu-sig web page @
python, so I think it'd eventually make sense to them to see that we're just
one big happy family.
Speaking of which, I did talk about Guido being the BDFL, and a Monty Python
fan (hence so many of the allusions throughout).
I also shared about how I fell in love with APL at Princeton in the 1970s
(Iverson passed away recently, maybe some of you know).
More information about the Edu-sig