Almost two years ago, I started to learn programming with Python. I had ignored coding for the longest time of my life, except for the unavoidable snippets in PHP one needs when setting up a WordPress or something similar. And of course the bumping ball in Amiga Basic back in my childhood days. But then I started working on a project for which I actually needed at least some programming skills to get things done (it’s a citizen science project called „Lingscape“, in case you’re interested). As a consequence, I started to ask a good friend of mine, who also happens to be an expert in computer science – let’s just call him Dirk –, rather stupid questions about programming. Or proposed projects that clearly exceeded my skill level. That must have been annoying for him, but at least it got me going with Python because once I had a specific goal in mind, a project I wanted to realize, I could focus on the things and skills needed in order to do so. Basically one could say that I got lured into data science by the shift in my research interest, and by Dirk or course (thanks, by the way!).
Now, after two years of trial and error, peaks and lows in motivation, efficiency, and outcome, I consider myself an avid learner, but there’s still a lot that I can’t do in Python, or even grasp sometimes (curse you, argparse!). Still, coding has become a beloved routine of mine. And according to Dirk, I can even serve as a good example for scholars in the humanities who are willing to adapt to the digital era. I write and tweak scripts to work with data in my projects, which also constantly increases my programming skills. Then, some weeks ago, I was put in a strange position: I was asked to participate in a skills training for Ph.D. students of the Digital Training Unit (DTU) in the Center for Contemporary and Digital History at the University of Luxembourg. The workshop was supposed to cover the basics of text mining and machine learning to give the students a head start for their own projects. In the context of this workshop I was asked to teach a crash course in Python. As I said before, I consider myself to be a learner still, so I thought, „how would I be able to do a tutorial like this?“ Plus, there’s tons of good introductions to Python on the internet. But then I gave it a second thought. Not only would the workshop be a good opportunity to pass on the things I’ve learned so far to the next generation of learners; transforming my knowledge into something that can be taught would also be a good exercise for me. Maybe it would even an advantage to be still in the process of acquiring the language for this kind of tutorial because my programming routines are somehow fresh and permeable to beginner’s problems with coding. And I have vivid memories of all the mistakes I’ve made, all the difficulties and obscurities I had to master along the way, so maybe me teaching from a learner’s perspective would be the exact thing needed for such a workshop.
Of course it is not up for me to decide if I was right about this – and successful with my lecture, but I decided to take up the challenge, and I have to say that I really enjoyed preparing and teaching this tutorial, also because the digital training unit turned out to be a group of very nice and talented people. Luckily for me, I could make use of excellent existing teaching material for Python learners. Out of the many, I decided to work with two simple example programs that are part of Dirk Hovy’s tutorial „Python for linguists“ that is available on Github. Not only is this tutorial well-conceived and quite accessible, these programs were also the very first lines of Python code I typed into a keyboard myself and I found them to be very useful to get an idea of the basics. On top of these exercises I decided to recommend Al Sweigart’s book „Automate the boring stuff with Python“ to the students. Although I’ve come across a lot of good introductions to Python over the last years, this one I like in particular, not only because it is available for free online, but moreover because it is written for beginners without treating them as idiots.
The overall aim for the tutorial was to introduce the students to the basic concepts and logic of Python in a hands-on approach. This type of tutorial is fairly common in the community, and I think it is a really good practice to start with some exercises, also because having concrete goals in mind helped me a lot in getting started with programming.
Therefore, I decided to build my tutorial in three steps: First, I wanted to give the students a general idea of what programming is and how it can be put to good use to solve research questions. Second, I wanted to introduce fundamental Python concepts like assigning to variables, building for-loops, and working with input/output to build a first little program together with the students. And third, I wanted to build a second program with the group that takes up most of the elements from the first program while also introducing some new elements like dictionaries, control structures (if … else), writing to files, and working with arguments to run scripts from a command line tool. Plus, the programs should serve as preparatory examples for the text mining tutorial to follow the next day. As I said before, I could make good use of the program examples in Dirk’s tutorial, so basically I only had to rebuild the material to match the group’s needs, also as an exercise for me, and enrich it with some details I found could be interesting for a text mining workshop. I prepared a presentation and two interactive jupyter notebooks which to me are a particularly useful learning environment for beginners because they make it possible to execute Python code directly in the notebook. Such a graphical approach makes the very first steps with programming very easy.
So I felt well prepared when the day of the training finally arrived. As it turned out, my preparation was sufficient, and my feeling is that I managed to demonstrate the most important aspects of programming in Python in an accessible manner. Still, some things didn’t work out the way I had hoped they would, but that was (hopefully) mainly due to problems with the technical infrastructure. We had asked IT support to deploy the widely used Python platform Anaconda on all machines in the computer lab before the workshop. Sadly enough, many of the participants weren’t able to access the Anaconda installation on the lab computers because a system wide Anaconda installation requires admin privileges that were of course not available from the participants‘ network accounts. Maybe one could have known this in advance, also since it is stated clearly in the first paragraph of the installation guide for Anaconda. But well… In the end we managed to run the notebooks via the online trial version of juypter so that most students were able to work with the example programs I had prepared.
Summing up I would say that – at least from my perspective – the workshop was a success despite the technical problems. And I hope that some of the students will profit from my tutorial. But I guess we will find out about this soon since all participants will be reporting on their experiences with the workshop in a post for the C2DH blog. More generally speaking, my impression is that the entire workshop (there were two other training sessions in this workshop, one about text mining with the nltk package and one about web scraping with various tools) could have been way more efficient and adjusted better to the participants‘ needs if there had been better communication and coordination between the three lecturers (including myself). Also it could have been helpful to have a concrete definition of desired outcomes for the training in advance. But well, every new structure needs time to develop its routines, so does the DTU. And so do I as a python instructor. As for the question of whether or not teaching Python from a learner’s perspective can be useful in this regard, I can only say: yes, absolutely! Preparing this tutorial forced me to break down my Python knowledge and the things I wanted to say about programming in an accessible manner while being precise about the basic concepts at the same time. This was a great exercise for me and I can only recommend it.
But there’s more think about in the context of this tutorial, especially regarding the way I prepared the material. Therefore, in the second part of this reflexion I will discuss the different tools I used and the ways they mesh because the way my workflow has evolved over the last two years also mirrors the transformation of my work routines as a humanities scholar in the realm of digital methods and data science.