[Edu-sig] Re: Python Programming: An Introduction to
drlinux at columbus.rr.com
Fri Dec 12 15:10:03 EST 2003
On Friday 12 December 2003 14:00, Kirby Urner wrote:
> I'm reading John Zelle's book, a real CS1 text book with exercises,
> Python as the language.
> This is an exciting book (see my concluding remarks below). I agree
> the blurbs on the back. E.g. Russell May of Morehead State University
> writes "This text does an excellent job of filling a gaping hole in
> Python community -- a textbook for an introductory computer science
> It is as good a text as I have read for CS1."
> Zelle has a lot of experience teaching CS1, back to Pascal days. I
> his sense of what belongs in a CS1 course in your average community or
> 4-year college. It's a fairly gentle slope by design, and Python
> What frustrates me somewhat is that CS1 doesn't really show off the
> power of Python, and by the time we get to CS2 at Zelle's academy (and
> suspecting this will be somewhat typical), we're on to Java. The
> is solid: real CS majors need exposure to a static-typed language, as
> as to more than one language. I have no problem with this reasoning.
We've (Capital University in Columbus, OH) used John's book
(prepublication copies) the last two years in CS1 and I agree that
it's a great book for beginners. When I taught CS 2 this year, I used
a mixture of Python and C++. I started with Python and covered basic
data structures (stacks, queues, linked-lists, trees) and operator
overloading. I was able to cover this in about 1/2 to 2/3 the time it
previously took me to cover this material in C++. I then spent the
last part of the course introducing C++ and covering the same topics
in C++ (along with the details of dynamic memory management). Overall
it worked well (especially considering this was the first time I'd
tried it and didn't have a textbook for it), but the students felt
they weren't very good at C++ programming. I basically made my own
course notes and had the students buy a CS2 C++ book so they had C++
code to look at and mimic.
I'm toying with the idea of writing a book that covers CS2 topics with
Python and C++ as described above but given my workload, it would be a
couple years before it was done and writing prose isn't my favorite
thing to do so I'm almost hoping someone will beat me to it.
In our advanced data structures I had juniors who had been taught
CS1/CS2 with C++ and sophomores who had learned Python and 6 weeks of
C++. Many of the juniors had seen some Python from seminar
presentations and a software engineering project the year before. I
started out with a double-linked lab and paired up the students so I
had one "Python student" and one "C++ student". I had one or two
groups with "two Python students" but tried to make these some of the
better students. I had them writed the lab in Python and then convert
it to C++. This worked very well and the "Python students" gained
confidence in their C++ skills. Most of the other labs were done with
students working by themselves and I let them choose which language
they wanted to use. Not surprisingly only a few students chose C++ for
the other projects (and I even offered bonus points for labs written
in C++ since it would be more work).
> The frustrating part is this means cool CS2-level features of Python
> get much if any airplay. Syntax overloading is not taken up, and many
> concepts get only initial treatment (e.g. no discussion of class vs.
> instance properties/methods, nor of multiple inheritance). No list
> comprehensions, generators, regular expressions. No passing of
> parameters to other functions. No numarray, nor much use of the
> library beyond math, random, string and Tkinter (which last is wrapped
> simpler module, graphics.py). No default or optional parameters.
Some (but obviously not all) of those topics seem beyond CS2 to me. In
my programming languages class I have students work in groups of 3-4
and present a language to the class at the end of the semester. They
write a few programs to demonstrate some of the features of the
language. In the past, students have chosen Python, Perl, Ruby, Visual
Basic, C#, PHP, etc. This January since the students will already know
Python I'm considering letting one group do an "advanced Python" where
they would cover many of the topics listed in the previous paragraph.
> Try-except *is* covered, as is eval() and docstrings.
> Again, I'm not questioning Zelle's judgment re what's appropriate to
> He has long experience in this domain. He's fully aware of what
> do, and just had to make these necessary cuts. It's probably somewhat
> painful to him as well, as when James Cameron (movie director) had to
> out reel three of 'Aliens' in order to have it fit the movie-house
> constraints of the day (reel three is restored in the extended play
> So let's assume a future in which Python is wildly successful as a CS1
> language, but with this pattern of moving on for CS2, with the sense
> Python has well-prepared students to tackle something thornier. Given
> bright future, I still have this lingering concern that Python may
> eventually be typecast as a "beginner language" in the sense of being
> sophisticated enough for higher level development.
> As Guido concludes in his short forward: "Reader of this book,
> congratulations! You will be well rewarded for studying Python. I
> you'll have fun along the way, and I hope you won't forget your first
> language once you have become a proficient software developer."
> I think it's this hope that I'm echoing as a concern. How will we
> that Python continues to receive attention even *beyond* its
> virtues as a beginner's language?
I'm not overly worried about this. As most of us do, the students find
writing code in Python more enjoyable. As long as instructors allow
the students to use Python in some of the upper-level classes, I think
students will learn more about Python and see how powerful a language
it is as well as an excellent language for beginners.
> When I try to think about how to get deeper into Python within a CS
> curriculum, I come up with a few ideas:
> (a) push more compsci content into the earlier grades so that CS1
> more quickly from the beginning, and therefore get further. E.g. if a
> of the students coming in already know some Python, this would be
About the only thing I've pushed into CS1 is GUI code (not the
traditional event loop) that John's graphics.py module makes very
> (b) keep the Python thread alive in CS2 even as Java is introduced,
> potential to bridge the two using Jython. This keeps Python around
> contrast. This may actually be closer to Zelle's own approach, as he
> mentions at his website using Python as "pseudo code" for Java-based
> implementations (but then current Java doesn't do operator overriding,
> some cool features of Python would still be missed using this
I agree with this, but think it makes more sense to use C++ so the
students get a feel for the lower level issues (memory management)
that Java hides and the operator overloading issue you mention. We
have a two credit Java course (with a CS 2 prerequisite) that most of
our students take since they see it as important for their resume.
> (c) think about returning to Python in CS3, if there is such.
> (d) return to Python in some of the more specialized classes having to
> with graphics, computational geometry, statistics or other specific
> applications (a recommendation similar to (c) I suppose).
I think a programming languages course is a great place to cover some
of the advanced topics (whether the instructor covers it or has the
students do a presentation on it). And again, allowing students to use
Python for some upper-level courses seems sufficient to keep their
interest in learning more about Python.
> (e) keep jiggering with the CS1 curriculum to squeeze more in, even if
> students do not come in more prepared.
I'm not certain how feasible this is. For us, Python allows us to
spend more time on problem solving (vs. C++ where we spent time
dealing with syntax issues, compiler errors, etc.). I think that
(problem solving) is more important in CS1 than advanced Python
> When considering option (e), my attention goes to the Point class. If
> Point does is hold x and y coords, then a class implementation seems
> overkill in Python. You could get by with built-in tuples. But what
> make a Point slightly more interesting by making it a Vector? Then
> put in __add__ __sub__ __mul__ and __neg__, as well as length(self)
> maybe even dot(self,other) and cross(self,other) -- do one in the
> leave the other for an exercise. Then there's conversion to/from
> polar/spherical coordinates.
> Such a Vector might still be used as a parameter to Rectangle and
> constructors, as in the current version, i.e. it could start out as a
> (x,y) container, and gradually mature as new OO ideas are mentioned.
> Another approach would be to add a chapter called something like
> Ahead' or 'Advanced Python', wherein a lot of these cool features were
> covered rather quickly and briefly, the intent being to give students
> foretaste. Those students most enamored of programming and wanting to
> more quickly, could be directed to this chapter and a
I'd rather see this in a CS2 book.
> However, none if this is about detracting from the worth of the text
> stands. I believe Zelle is perfectly positioned to press Python's
> is doing a very credible and creditable job of it.
> He's clear in his intro that his goal is less to teach Python than to
> an overview of important computer science concepts that students will
> re-encounter in just about any language. He's consciously eschewing
> Python idioms (list comprehensions?) in favor of a more generic
> because mastery of Python per se is not the main goal. I understand
> Through his efforts, I'm hoping we quickly get to the point where
> for Python" as a CS1 language becomes a no-brainer, i.e. it's not even
> point of controversy. I think this text moves us a big step in that
> direction. It's clear, it works, and it should easily go into
> future editions.
I hope so too.
More information about the Edu-sig