How I Learned to Stop Worrying and Love Python

Jakub Kvapilik
CEU Threads
Published in
6 min readMar 1, 2024

Everyone is talking about AI these days. Some people are anxiously worried. Some people are happily enthusiastic. I suppose I am neither. I will likely not join “camp AI” anytime soon. However, I am rather inclined to join “camp Python”. Let me tell you how that happened and what Central European University has to do with it.

Source: Joshua Reddekopp/Unsplash

As a PhD student with empirical focus, I have already done a fair share of programming with statistical tools. Bachelor's thesis in Stata, Master's thesis in R, PhD dissertation in Stata again. Not that I have ever considered myself a programmer. But still — data, data, data. That's the cornerstone of “real” research these days. (Sometimes I get even mildly annoyed with this data obsession, though: is reality only about data, models and empiricism? Many philosophers would say no. In any case, models without a solid theoretical background make little sense. Also, if you need to explain agent behaviour, will you not need something like psychology or even ethics or metaphysics? What is the definition of science, anyway?)

My current PhD research focuses on empirical legal research whereby I look at judges and how they systematically differ e.g. in their decision patterns or time needed to decide a case. Stata can handle that just fine. But hey, there is more behind the horizon. I would like to analyse the actual text of the decisions. How do judges reason? Whom do they cite? Is precedent important for them? Do tax-case decisions have a text structure different from asylum cases? Sounds like a task for Python.

But I did not know Python. And there were potential concerns, at least in principle. Will an economist by training manage to learn a programming language? Is it worth learning something that many people say AI has erased the need for? Against the backdrop of these uncertainties, I enrolled in the introductory Python course with Professor Muço at the Central European University.

Her introductory course is open to anyone meeting the mild prerequisites given and willing to engage in her friendly, welcoming classes. She is an outspoken fan of AI and allows students to make use of whatever their favourite GPT-chatbot happens to be. We should embrace progress, she would say.

AI-powered learning

And admittedly, AI helps. Chat-GPT, Bing Copilot or Google Gemini are like a personal instructor on your journey into the “real” programming wonderland. (I guess all Python/Java/C++ people look down on Stata and, frankly, they are likely justified in their reservations.) Can you look at my code and see what is wrong? I need to simplify this function — is there an easy way to do this? Please tell me how this code works — and can you make it easy to understand for a beginner? All these questions are no big game for the AI. And furthermore, you can ask again. Where a human instructor would easily get irritated, there is nothing like running out of patience in the case of our GPT “friends”.

However, to be able to ask properly, you also need to understand how the AI models work. And surprise, surprise, they're often written in Python. Amusing, isn't it? One learns Python with AI to understand AI coded with Python.

To walk you through the basics of Python programming, Professor Muço's course makes use of various quasi-realistic settings of e.g. a plumbing company (Modern Plumbers) wanting to record their logged hours worked and overall compensation in a Python notebook. And why not, actually? One cannot stop technological progress even in plumbing companies, I suppose.

With a good pedagogical intention, Professor Muço uses the plumbers example at various stages of the course. So you get to solve the same task repeatedly but with more advanced tools and concepts in the back of your mind as the course progresses. One is thus invited to think again and again, this time maybe arriving at the solution in a different or more efficient way. This was also the case with the final assignment where Modern Plumbers came to the stage again. For example, functions were not a thing at the beginning of the course, but now, they were the way to go.

Friend or foe?

Moreover, there is more than just programming that you take away from the course. We were challenged both in class and in the assignments to think about the intertwining effects of AI, technology and the possibility of change in general. Should we be worried about AI? Should we fight against technological progress? Is change possible at all?

When it comes to assessing the impact of AI, one cannot neglect the obvious advantages it offers. Is it useful? Can it enhance our productivity and automate repetitive, mundane tasks sometimes encountered in universities or business? Sure. Having taken Professor Muço's course, I can moreover see the immense horizons of learning opening up in front of everyone — rich, poor, privileged or marginalised. Anyone with internet access can now learn in a better, faster, and more personalised way than before.

However, there are downsides to relying on AI too much. What happens when we outsource our thinking to the machines? Will we not be too lazy to be bothered to dive deep into complex issues and try to grasp non-intuitive concepts on our own? Will we ever do a literature review ourselves again? Will certain parts of our brain die forever?

Let me point out an example with old-school calculations. Can you do the multiplication of 52 and 49 in your head? I guess you can — but I assume it will take you some time and at this point you have probably started looking out for a calculator or your smartphone. Previous generations could do that without any issues, thus manifesting more agile mental capacity. Why? Because there were no calculators.

I think the same danger, but on a massively larger scale, is associated with the use of AI. And it is likely to exacerbate many of the already existing issues. As of now, teenagers do not read. Modern generations appear to be less smart, objectively speaking. Standardised test scores in many countries are falling or at least stagnating. If we outsource much of our cognitive abilities to the AI, what will further happen to our reasoning? Will reading, thinking and debating become a luxurious good for those who have the time or resources to engage in it?

And what about privacy? The more you ask the AI, the better it becomes. It trains on the data you provide. Further, it can now remember you and your queries. Is Chat-GPT going to become just another, sophisticated database of your private information to be sold to advertisers or stolen by hackers?

Finding the middle ground

I do not propose giving up the AI. But, said with Aristotle, we need moderation. Technology is a means to an end. We need how to learn to use the new AI tools so that they enrich, not detract from, our humanity. I think AI should be explored further, but with safeguards in place. Nobody wants an I, Robot scenario happening. And the same should apply to social networks, the internet or virtual reality. Many wise people have already come up with ways to rein in the potential harm, especially in the case of teenagers.

Throughout the course, Professor Muço did not forget to bring these issues to our attention. We were told not to delegate thinking to the AI. Also, there were bonus points for assignment submissions featuring non-GPT solutions. Nevertheless, this is easier said than done. With an assignment due in a couple of hours, the easy way out is just to ask Chat-GPT to deal with the task at hand. Student mentality is a force majeure, I am afraid.

Python itself, however, is still a tool in the pure sense. It does only what you tell it to do. And it is very versatile. From regressions through text analysis to visualisations, it delivers the magic in a few lines of code. Despite my initial uncertainties, I now think Python has the potential to become one of the main tools I use in my research.

Sure, I am very far from being an expert at this point. But I would like to explore further. For example, can you make a function that takes another function as argument? It appears you can. We did not cover this in class but I learned that you might use these so-called higher-order functions for e.g. various text transformations or even sentiment analysis.

To conclude, I believe Python offers a great programming environment to anyone who needs to work with data and especially text analysis. And AI has made learning to code much easier. Nevertheless, I would argue against embracing it unconditionally for various reasons. That said, we should not be afraid to use it — rather, we should use it wisely.

--

--