[Edu-sig] teaching with python experience
Massimo Di Pierro
mdipierro at cs.depaul.edu
Tue Apr 1 02:06:25 CEST 2008
You can find the original course proposal that I wrote at
This predates the idea of using a web framework. I do not have
assignments because I did not teach this course myself.
On Mar 31, 2008, at 4:08 PM, ISHWAR RATTAN wrote:
> Hello Massimo,
> I would like more details on introductory sequence
> courses: info covered and programming assignment statments
> (if possible).
> I am not a fan of Python but this might be the right
> first programming language for undergraduates (like a
> throw back Pascal days).
> - ishwar rattan
> On Mon, 31 Mar 2008, Massimo Di Pierro wrote:
>> Hello everybody,
>> I would like to share some of my experience in teaching Python at
>> DePaul University in Computer Science. The main problem we have been
>> facing with C++ and Java courses is that it takes years of practice
>> before students are able to develop something interesting. We tried
>> different approaches:
>> 1) We created an optional introductory sequence in Python (in
>> alternative to Java or C++, but they still have to learn Java and C++
>> in more advanced courses). Students who take the class tend to be
>> generally more knowledgeable of CS concepts than students who choose
>> the Java and C++ intro courses (who chose them because they have
>> heard of the names).
>> 2) We use Python more and more in courses that are not language
>> specific. For example I teach graduate courses on Monte Carlo
>> Simulations for Financial Applications, a course on Scientific
>> Computing and a course on Parallel Programming. In all these courses
>> I use python instead of pseudo code and the students get it right
>> away even if they have not been trained in the language. In some
>> cases they have to translate python in C++ but Python helps them
>> separate the complexity of the algorithms from the complexity of C++
>> 3) We created a new course on web frameworks in Python. The course is
>> not on the usage of one particular framework, although we had to
>> choose one, but on the programming patterns used to develop
>> frameworks. This course was targeted to both undergraduates and
>> graduates students in order to fill gaps in their knowledge. The
>> basic idea was to follow the path of an HTTP request from the moment
>> its is generated by a browser until it reaches the server, is
>> processed and the response is sent back. We discussed good practice,
>> security, different types of persistence (database, cookies,
>> sessions, filesystem, ram) and the Model View Controller design. Most
>> of the students had no previous python experience and no server-side
>> programming experience. They all new HTML but minimal CSS and zero
>> knowledge of network protocols such as HTTP.
>> After evaluating a number of web frameworks and having tried to teach
>> a previous course using Django I found that most of the existing
>> frameworks have a too steep learning curve. A typical problem for
>> example is the need for shell commands (Ruby on Rails, Django,
>> Pylons, TurboGears, they all require use of a shell) but most
>> students have only bee exposed to windows and they the concept of
>> shell very alien to them. In order to solve this problem I wrote
>> http://mdp.cti.depaul.edu (TRY THE LIVE DEMO ONLINE) (GPL
>> specifically for these students. This experiment had more success
>> than expected and all students in the class have been able to create
>> decent projects using the framework and the best students got more
>> involved the core development, joined the mailing list and were glad
>> to give a real contribution to their first open source project. For
>> some reason, since then, web2py has picked up some steam more in the
>> business environment than in the teaching environment.
>> Although my class was not targeted to freshmen, it could have been
>> (with some changes).
>> My experience with 3) is that students appreciate programming better
>> when they develop something that they can use, that they can show
>> their friends who are not computer scientists, and they get it. One
>> way to do it is by programming inside a web framework (whether it is
>> web2py or Django or Pylons does not really matter).
>> Some things are different and some things are the same when compared
>> with teaching "normal" programming:
>> a) One visits a URL and a function is called, the output of the
>> function is sent back to the browser. You still has to write the
>> function, but the concept is more intuitive than calling a function
>> from main(). They get it right away because it is related to their
>> everyday experience. They also understand parameters passing because
>> they are familiar with filling forms online. In the case of a full
>> stack framework all of the work is actually done by the framework
>> itself, the students only have to write the function the "returns"
>> the response as a string.
>> b) Conditionals are not much different than in "normal" programming.
>> c) Loops are somewhat less important in the initial phase because
>> there is a lot one can do without looping. This is good because it is
>> with loops that students have the most trouble.
>> d) Most web frameworks abstract the access to the database, therefore
>> adding real database persistence is not much more difficult than
>> using a member variable of a Java class. This enables students to
>> created rich functionalities with a small set of API.
>> e) cookie, sessions and cache add a small level of complexity but a
>> good web framework should be able to take care of these issues
>> transparently. web2py does. Django, Pylons and TurboGears doo to
>> although they require some configuration.
>> f) They do not need to know HTML because they can use an HTML WYSIWYG
>> Moreover in doing web programming at a more advanced level, two
>> crucial CS tasks show up naturally: regular expressions (for
>> validation of user input) and parsing (for reading HTML/XML/XML-RPC/
>> RSS and for all kind of tasks like parsing code embedded in a web
>> page, for performing syntax highlighting, etc.). These are concepts
>> that every CS major should know but we often teach them in ways that
>> do not relate to the everyday experience of the students.
>> Anyway, the bottom line is that instead of start teaching programming
>> using programs that interact with a shell or with a GUI, today it is
>> becoming easier and easier to write programs that interact with the
>> web. There is a small overhead but a lot more power and fun for the
>> Personally I am going to follow this approach in other courses that I
>> am teaching that do not require python and do not require web
>> development. If you want to try it too and have questions let me
>> know. I will be happy to share my experience and material.
>> Edu-sig mailing list
>> Edu-sig at python.org
More information about the Edu-sig