Basic scripting (programming) with Python
Hi everyone,
You've already come so far. I'm very impressed with how quickly you've picked up Git and its associated lingo.
You're at the point, believe it or not, where you could easily learn some basic coding skills!
So, to celebrate, I put up two simple scripts in the new scripts
directory. The files contain a lot of comments, and not really that much code. The files do more or less the same thing.
- The basic version, wordcount.py, is a minimal script for getting word frequencies in
data/alice.txt
, an example text file (Alice's Adventures in Wonderland, by Lewis Carroll). - count.py is an extended version, designed to be reusable on any text file, any time.
Writing things like wordcount.py
would make you a scripter, capable of writing tools that help you in your own research. Writing count.py
is more like being a developer, writing code that is reusable and usable by others. The main difference in terms of functionality is that while wordcount.py
allows you to get word frequencies in alice.txt
, count.py
allows you to get word frequencies for any file you like.
Learning to code is beyond the originally imagined scope of the class, but you're certainly now at a point where you could learn. In this issue, let me know if you're interested in learning basic scripting with Python. If the class is, I'm happy to spend a bit of time showing you how to write and run things like wordcount.py
and count.py
. Depending on what @martin.dusinberre thinks, this could go into regular class hours, or it could be an optional "seminar" that the interested could join.
I will do what I can to keep all coding exercises practical for history: we can do text analysis, or perhaps learn to generate charts that aid in the interpretation of quantitative history data. We could work with any existing history dataset, so if there's some data you know and like, discuss that here too.
I should also stress that nobody is forced to learn scripting --- it is beyond the official scope of the course. It's totally appropriate if you'd rather concentrate a little more on the history side of things.