Sign In

Communications of the ACM

News

Python For Beginners


Python logo

Credit: Python Software Foundation

The way Taylor Poulo sees it, learning to code in Python is comparable "to learning Latin and romantic languages." Once someone grasps the logic behind Python, the concepts can be more easily transferred to other languages, maintains Poulos, a senior majoring in industrial engineering at the Georgia Institute of Technology (Georgia Tech). "Once you get comfortable thinking in a different type of logic and using different words, it's much more comfortable to learn new things," she says, adding that she was required to take three computer science classes at Georgia Tech, all in Python. "Python did that."

Python, an open source scripting language, has become the most popular introductory teaching language at top U.S. universities—Georgia Tech among them—according to a recent survey by Philip Guo, an assistant professor of computer science at the University of Rochester. Guo decided to conduct the research after noticing anecdotally over the past few years that Python was replacing languages such as Java as the de facto introduction to programming class in more and more computer science classes at universities around the country.


Comments


Rodrigo Dias Arruda Senra

Dear community,

I would like to respectfully disagree with the following statements:

* "Additionally, Python has limited support for testing, he says."
* " ...onerous for beginning students"

Python has extensive support for testing, just check: unittest, py.test, nodetest, lettuce, splinter and mock to name just a few.

Moreover, it has native language mechanisms that allow dynamic introspection and injection (mocking and patching) that are vital to create flexible and unencumbered testing frameworks.

Another issue is the ease integration between Python and C, that allows teachers to ask their students to create libraries implemented in C (for studies about data structures for example) and automatically test them in Python. I did that as early as 2003, and spoke about it during Europython 2005.

best regards,
Rodrigo Senra
rodrigo.senra.nom.br


Marc Auslander

I was curious about Krishnamurthi's thoughs on structure. I was initially frustrated by python taking me back to my fortran days when comments documented the meaning of columns of an array!

But after playing with the namedtuple and (not built in) namedlist modules, I'm quite a bit happier. I have structs back - but structs which are wonderfully polymorphic, iterable, and quite natural.

I suspect Krushnamurthi is thinking of something richer than this - and I'd love to hear his comments or a pointer to an elucidation of his criticism.


Devon McCormick

The article mentions how "...Python allows you summarize a list of data in one line of code" and how useful this is.

I'm glad to see that at least a few people are starting to understand what we've been saying in the array-programming community for decades.


Shriram Krishnamurthi

@RodrigoSenra: I'm certainly aware of the testing infrastructure. However, library support for testing is never quite as simple and clean as having it integrated into the language, and the more friction there is the more barriers you erect to adoption. Many introductory courses do not talk about testing at all, or talk about it poorly. In particular, most people completely miss the difference between _testing_ and _examples_, the latter being used to drive the design of the program inductively. Nobody would write examples without good language support to make it as lightweight as possible, and indeed few do.

If you haven't, please look at how the student languages in Racket (e.g., http://docs.racket-lang.org/htdp-langs/beginner.html?q=check-expect#%28form._%28%28lib._lang%2Fhtdp-beginner..rkt%29._check-expect%29%29), or Pyret (http://www.pyret.org/), integrate testing and examples into the language. There is enormous pedagogic experience of the effectiveness of this. We even have studies of how well this works for peer-review (e.g., http://cs.brown.edu/~sk/Publications/Papers/Published/pkf-ifpr-tests-tf-prog/).


Shriram Krishnamurthi

@MarcAuslander: there's a difference between using built-in datatypesof which there is indeed a rich collectionand learning how to create your own. You may indeed be settling too easily! Do you also have built-in trees? Which kind: binary trees? N-ary trees? Balanced binary trees? Family trees? If so, ascending family trees or descending family trees or both?

Of course you could find libraries that implement these, but a programming course should also teach students to build their own. Also, if you follow a data-driven program design methodology (as in http://htdp.org/), you will find built-in structs quite insufficient because they do not give you rich, structural information about their components. That's why using built-in datatypes gets you only so far. However, because most introductory programming curricula have no clear design methodology, they don't notice this absence.


Allen Downey

We are proud that you recommended our book, How to Think Like a Computer Scientist as further reading on Python for Beginners. But we are disappointed that you did not acknowledge us as authors. The original version of this book was written by Allen Downey, Jeff Elkner, and Chris Meyers, and published by Green Tea Press (greenteapress.com) under the GNU Free Documentation License. This license allows anyone to copy and distribute the book, and to make modified versions.

The online interactive version of the book was converted and substantially revised by Brad Miller and David Ranum and is published under the same license. Since the interactive edition was published many people from around the world have made contributions and suggested changes on github.com/bnmnetp/runestone.

Free textbooks are popular and valuable resources, and they encourage and make possible successful collaborations like ours. But one of the barriers that discourages authors from working on free textbooks is the worry that their work will be appropriated and used without acknowledgement. We are sure the Communications of the ACM did not intend to compound this worry by presuming that online resources are authorless, unprotected works.


Esther Shein

Thank you for expressing your concerns, Allen. It was not our intention to slight any of the authors, whose names are clearly referenced when one clicks on the link to the interactive book listed under further reading material. We also made no suggestion, nor did we imply that the group's work should be appropriated and used without proper acknowledgment.


James Heliotis

In response to Dr. Krishnamurthi's quote about problems with Python and data structure, we agree with that sentiment. Last year we tried a solution whereby a superclass would create all the "standard" methods one might need. The student need only write a "class" header line and then the names of slots. What s/he gets for "free" is a constructor, equality tester, hash function, and string rep. function. (Some of these have limitations to non-cyclic structures.) We even added optional type "declarations" in the slot spec. This is because as our students get to the end of time that they're using Python, the lack of type checking gets to be a significant problem in rapid software development. If you're interested, please feel free to contact me. -James Heliotis, RIT.edu


View More Comments

Log in to Read the Full Article

Sign In

Sign in using your ACM Web Account username and password to access premium content if you are an ACM member, Communications subscriber or Digital Library subscriber.

Need Access?

Please select one of the options below for access to premium content and features.

Create a Web Account

If you are already an ACM member, Communications subscriber, or Digital Library subscriber, please set up a web account to access premium content on this site.

Join the ACM

Become a member to take full advantage of ACM's outstanding computing information resources, networking opportunities, and other benefits.
  

Subscribe to Communications of the ACM Magazine

Get full access to 50+ years of CACM content and receive the print version of the magazine monthly.

Purchase the Article

Non-members can purchase this article or a copy of the magazine in which it appears.