Early in 2000, not long after Guido announced the now defunct Computer Programming for Everybody (CP4E) project, the late Frank Willison interviewed Jeff Elkner, an inspired high school teacher at Yorktown High School in Arlington, Virginia who was using Python instead of C++ to teach programming. He hoped to make programming more accessible to all students by using Python.
The project has matured since then, reaching more students and reaching further out into the world. The Python community at Yorktown has grown up and the programming culture has grown. The students help each other out and do more advanced things each year. This year, Elkner is using pyKarel, a tool his own advanced students have helped develop, to teach his new students.
PyKarel is a Python implementation of Karel the Robot. Introduced in the 80's, Karel was intended to jump-start students in the Pascal programming language. A virtual robot moves about a maze, interacting with walls and beepers, performing programmed tasks. It has a Pascal-like structure, but only five commands: move, turn left, pick beeper, put beeper, turn off. There are 18 or so conditionals that are mostly repetitious "if facing north", or "if facing south." There are no variables. Karel's virtue is in being both visual and simple.
Python programmer Steve Howell, reminiscing about his introduction to Karel back in college, wrote the first version of pyKarel. PyKarel takes Karel programs and translates them into Python programs. Howell wrote the original visual component as a curses program. Essentially, it was ASCII graphics. After writing pyKarel, he looked for someone to use it. He contacted Jeffrey Elkner whom he knew through the Python Edu-Sig mailing list.
A couple of Elkner's more advanced students began working with pyKarel. "I was surprised by how little I had to do to keep the project going," said Howell. "The kids took over, and the project took on a life of its own." One of the first things they wanted to do was get rid of the curses interface and make pyKarel a bit more attractive. They decided to use wxWindows instead, and for assistance in that they turned to Python developer Michele Moore. Aside from a bit of mentoring from Howell and Moore, the developers of pyKarel, Waseem Daher, Donald Oellerich, and Lex Berezhny, are all students.
"I wouldn't be able to teach the students the things they are learning developing pyKarel," said Elkner. "Steve is a professional programmer. He can take them beyond where I could. To me, the most exciting thing (about this project) is the idea of the classroom not stopping at the classroom walls."
Many professionals like Howell and Moore would like to mentor, but find it too difficult if it means taking a couple of hours to come to the school. With email and the Web, it's much easier for them to be involved. "She's playing a big role in helping student's develop," said Elkner. "A couple of years ago that just wouldn't have been possible. With the Internet, my classroom doesn't end. It's boundless."
PyKarel is also a valuable tool for the newer students. Elkner started this year's first-time students with three weeks of programming Karel the Robot. The new students got to use the tool the more advanced students were helping create.
The course isn't just for future programmers. It's an elective that everyone can take and is intended to reach a broad audience. For many of the students, this may be their only programming experience. It is not a stepping- stone to something else. Simple and visual, Karel the Robot quickly gives them a taste of success. "Too much straight programming loses students," explains Elkner. "They get so frustrated that they can't do it that they feel like 'programming is not for me.' Using Karel the Robot this year I am struck by how fun they think it all is."
Elkner's new students are now done with Karel and moving on to Python. His more advanced students are not done with pyKarel though. They are looking at doing two things: creating an implementation of Karel++, a simple object oriented variation of the Karel language and pythonic Karel, using the Karel language, but with a pythonic instead of Pascal-like syntax.
Either should be easy to do, since pyKarel just generates Python. They should be able to generate the same Python from Karel++ or from a pythonic version. Elkner said he isn't sure about the pythonic version. "I am sort of torn. One of the things I like about Python is the indented block constructs, but one of the drawbacks is students have trouble getting what a block is in the first place. It takes them a while to get it." Karel's Pascal-like structure, with explicit Begin and End statements can make block structure clearer. Yet Karel was meant to be a precursor to Pascal. Elkner uses it as a precursor to Python.
"I am just getting them used to what a file is and how and where can you save it. That's enough of an issue," said Elkner. These new students also have to learn how to get around an operating system, specifically Linux. Elkner's classroom computers are about 90 percent Linux, though the more advanced students have been making sure pyKarel works correctly with Microsoft Windows systems as well. With so much to learn, he was happy to stick with plain, simple Karel for the first few weeks of programming.
Despite his reservations, what happens with pyKarel may be out of Elkner's hands at this point. With the students guiding pyKarel development, I wouldn't be surprised if they built a pythonic version of Karel anyway and then continued to build more things Elkner hasn't thought of yet. It's a true open source project, and you can't contain that in a classroom.
Stephen Figgins administrates Linux servers for Sunflower Broadband, a cable company.
Read more Python News columns.
Return to Python DevCenter.
Copyright © 2009 O'Reilly Media, Inc.