Unification of Methods and Functions

David MacQuigg dmq at gain.com
Fri May 21 08:08:20 EDT 2004


On Fri, 21 May 2004 13:45:52 +1200, Greg Ewing
<greg at cosc.canterbury.ac.nz> wrote:

>David MacQuigg wrote:
>> I'm still waiting for that one simple example that you say will do it
>> all, and do it right.
>
>I don't think you should be trying to cram all the features
>of OOP into a single example.

I agree.  Digestible chunks is the right approach.  Animals_1.py is
the first example of classes, including data, methods, instance
variables, and inheritance.  Thats a pretty large chunk, but what
makes it digestible is the student's prior knowledge of modules,
functions, and all forms of data.

Animals_2a1.py (the current version) adds more levels to the
hierarchy, a special method __init__, static methods, bound and
unbound methods, the odd scoping rule for class variables, and
_private variables.  This is all the basics that students will need if
they will be writing their own classes.

There probably won't be an Animals_3, but instead, "level 3" will be a
bunch of examples to illustrate various techniques, like the robust
programming that JM has been pushing, and maybe some topics from
chapters 21 - 23 of Learning Python.

>Also, I worry that the zoo topic will seem contrived. Why
>not base your examples on some real problems from your
>audience's subject area?

Given the goals of the level one and two examples ( cover all the
basic features in two simple examples ) I think any example will be
contrived.  The level 3 examples will be the right place to introduce
real circuit design problems.

-- Dave




More information about the Python-list mailing list