Reduce, Reuse, Recycle
Overview
This week we will look at how frequently-used code can be packaged up in functions and libraries. This is the point at which we begin to engage with code in a more abstract way because we are increasingly interested in reusability and flexibility.
By the end of this week you should be able to:
- Write functions with parameters, return values and type hints, and explain variable scope.
- Explain what a decorator does and apply one to a function.
- Import and use packages, and explain how namespaces prevent naming conflicts.
- Discuss how positionality shapes both data and their representation (Massey; D’Ignazio & Klein ch. 3).
- Agree ways of working with your assessment group.
- Watch the three pre-recorded lectures (≈ 30 min in total): Functions (12 min) · Decorators (10 min) · Packages (8 min)
- Read Massey (1996) and D’Ignazio and Klein (2020), making notes against the study guide questions. These two are demanding, so leave time for them.
- Think about who you’d like to work with: groups for the assessment form this week (see In-Person Lectures).
- Bring your laptop with Podman running. If you’re new to Python, do the Code Camp Functions and Packages lessons first.
Readings
Come to class prepared to discuss the following readings:
| Citation | Article |
|---|---|
| Massey (1996) | URL |
| D’Ignazio and Klein (2020) Ch.3 | URL |
Study Guide
- Reading Massey’s seminal “Politicising space and place”:
- What are the two conflicting geographical imaginations at play in contemporary society? Explain their contradictory nature.
- In the case study of ‘high-tech’ scientists, how do the ‘power geometries’ of work and home reflect gendered power relations?
- Looking at D’Ignazio and Klein’s “On Rational, Scientific, Objective Viewpoints from Mythical, Imaginary, Impossible Standpoints”:
- What does the “view from nowhere” concept mean in the context of data visualization, and why do they find it problematic?
- How do they propose to address the limitations of data visualization? Describe their concept of “data visceralization” and its significance.
- Why do they suggest that you shouldn’t never use the ‘god trick’?
These are two of the more challenging readings this term, but they are critical to understanding what we are trying to teach you: it’s not just about learning to code, it’s about learning how to deploy code/quantitative methods to support your argument, while maintaining a keen eye on how bias – in both the technical and the ethical senses – can creep into your thinking and, consequently, your results! In fact, the point would be that we are always biased one way or another, it’s just that many of us don’t stop to reflect on what that bias – or positionality – actually is.
Pre-Recorded Lectures
Come to class having watched:
| Session | Video | Presentation |
|---|---|---|
| Functions | Video | Slides |
| Decorators | Video | Slides |
| Packages | Video | Slides |
In-Person Lectures
This week’s session will provide additional detail on the assessments.
| Session | Video | Presentation |
|---|---|---|
| Group Working | In class | Slides |
| The Assessments | In class | Slides |
Practical
This week’s practical will be looking at how functions (and variables) can be collected into reusable packages that we can either make ourselves or draw on a worldwide bank of experts – I know who I’d rather depend on when the opportunity arises! However, if you have not yet completed Code Camp (or were not aware of it!), then you will benefit enormously from tackling the following sessions:
The practical focusses on:
- Seeing how functions and decorators can help us to reuse code efficiently.
- Beginning to make use of packages to access/interact with data.
To access the practical: