We had another fast-paced class on Python last Thursday. Rahul spent the first two hours on functions, classes, tuples, dictionaries, conditionals, and loops—all potentially mind-bending topics for anyone new to programming—then talked us through a program analyzing scholarly articles in the astronomical literature. The code, viewable in IPython Notebook or at nbviewer.ipython.org, compares word frequencies in the abstracts of articles classified observatory with those of articles classified science. Such analysis is a necessary first step towards teaching a computer to classify articles automatically. (Librarians, take notice!) Our collaborative notes (PDF 170 KB) on the session provide links to the code files we used in class and cover the main points discussed in the first two hours.
It was a lot to learn in three hours, and many of us will need to review these concepts at a gentler pace over the next several weeks. My own comprehension of the material was considerably aided by some former programming experience (very minor) and by a previous introduction to Python basics, but even with all that my head was full of new information by the end of the session. One participant with no programming experience likened what we’re doing to trying to learn French in one week. She said it’s like talking about direct objects in French when you don’t know French and you don’t understand the concept of a direct object. I thought this was an excellent observation. It’s certainly true that the words we use to talk about how languages work—“prepositions,” “direct objects,” “variables,” “functions,” “calling” functions—are like a language unto themselves. Learning these new concepts and the vocabulary associated with them takes time and repetition.
Which is all to say that we are very fortunate that Rahul has offered to come back for a third session this week! Being new to Python and programming, we need the scaffolding provided by lecture-style presentations, and Rahul has done a terrific job of quickly demonstrating the most important features of the language in the context of examples that relate to our field. But once his presentations are over, we’ll be largely on our own, and that’s when the collaborative nature of this course will take on its full importance. Chris’s original vision for this class was as a stimulating and supportive environment for learning through hacking, and we are sure to develop most of our skills on our Saturday hack days as we sit together and struggle through the many coding challenges we’ll encounter in pursuit of our project goals.
So, as we move ahead, two pieces of advice for the new programmer from Rahul’s presentation on Thursday:
1. Be lazy!
Always construct stuff so that you type less. Take every opportunity to create functions that you can use over and over again.
2. Don’t get yourself confused.
Choose meaningful variable names. Break complicated code down into more manageable chunks. Because if you’re confused as the programmer, no one will understand your code.