Workshop: Python (30 June–1 July 2022, University of Mannheim)
Held by Michael Percillier
Programme
- Thursday 30 June
- 10:00–13:00: Covering some of the basics (looping, variables, argument parsing, writing output) by generating the song 99 Bottles of Beer On the Wall and variations thereof (coffee break at around 11:30)
- 13:00–14:30: Lunch break
- 14:30–18:00: Our first real hands-on case: Converting a CorpusSearch
.out
file to a table ready to be imported to R or Excel (coffee breaks at around 15:30 and 16:30)
- Friday 1 July
- 10:00–13:00: Creating a spreadsheet based on manually annotated data, working with Tara’s 14th century Dutch data (coffee break at around 11:30)
- 13:00–14:30: Lunch break
- 14:30–18:00: Determining the distance between primes and their targets, working with Lena’s corpus data (coffee breaks at around 15:30 and 16:30)
Remote access
If you plan on joining remotely, please have a dual monitor setup ready so you can watch the stream and type in the Python code yourself simultaneously.
Setup
In preparation, you should install Python. The latest stable release of Python is version 3.10.5. If you already have Python installed, please ensure that you have at least version 3.6 or newer.
To install or upgrade Python, you can either:
- download and run the latest installer from https://www.python.org (relevant for Windows and macOS)
- use a package manager (relevant if you are using Linux, or the Homebrew package manager on macOS)
You can verify whether Python was successfully installed on your system by opening your Terminal or PowerShell and entering the command python --version
or python3 --version
. In addition to installing Python, you will also need a text editor. Here is a non-exhaustive list of suggestions:
- Mu: a simple Python editor for beginner programmers (limited to Python but very simple to the point of being suitable for children)
- Geany: a lightweight Integrated Development Environment (IDE) supporting over 50 programming languages, including Python
- VSCodium: the open-source version of Microsoft Visual Studio Code, i.e. a very similar product but without telemetry built-in. Both editors are fully-featured and contain many creature comforts for advanced programmers. However, the wealth of options may be overwhelming to beginners.
- Long-established text editors such as Vim or Emacs (only use if you are already familiar with them due to the steep learning curve)
Resources
- If you wish to read up on some basics in advance, you can work through the preface and chapters 1 and 2 of the e-book Automate the Boring Stuff With Python.
- Official Python documentation
- For regular expressions, you can consult the documentation for the
re
package and the tutorial on regular expressions from the Anglistik IV Toolbox - For XML parsing, you can consult the documentation for the package “Beautiful Soup”