[Edu-sig] Explaining Classes and Objects

Lloyd Hugh Allen chandrakirti at gmail.com
Tue Jun 14 11:24:01 CEST 2005


On 6/13/05, Chuck Allison <chuck at freshsources.com> wrote:
...
> they can handle just fine. After a little experience with the
> interpreter, they can easily pick up methods:
> 
> words = s.split()
...

I believe that "dir( )", when combined with an interactive shell, is
the most powerful command in Python. For an example, I made an
apparently overly-complicated database to interpret my school's
records. When I was trying to figure out which rooms were used by
which teachers (in both directions--room by teacher and teacher by
room), I started by doing dir(school) to remember what my categories
had been, and then eventually figured out what I could loop over and
what attribute I wanted. I eventually remembered that
school.classes.periods.teachers could be compared to
school.classes.periods.rooms in order to come up with what I wanted.

This is also how I explore modules with which I am not familiar, and
one of the first things I ask my students to do is to

import math
dir(math)


More information about the Edu-sig mailing list