Programming in Python¶
This series of lessons will cover the basics of a programming language called Python:
“Some things to think about before you exhort everyone to code”¶
Programming knowledge is not a neutral thing
Miriam Posner, a professor of DH and information studies at UCLA, wrote an excellent blog post about why people should think before they “exhort everyone to code.” In her blog post, Posner discusses that certain kinds of people, like middle-class white men, are more likely to be exposed to programming languages at a young age and are less likely to experience sexism and racism while learning programming languages. “Programming knowledge is not a neutral thing,” she argues.
Before we dive into Python, we want to acknowledge that programming knowledge is not a neutral thing or a natural thing. Further, programming knowledge is not a superior form of knowledge, and it is not the best way to approach every problem.
Why Learn a Programming Language?¶
With all that said, why might it be worthwhile to learn a programming language?
You can save time and energy by automating tasks
You can collect and analyze cultural data from a different perspective, often at a larger scale
You can gain more flexibility, customizability, and autonomy over your digital research projects
You can better understand how data and programming languages shape contemporary society and culture
Why Python Specifically?¶
Ok but why Python specifically?
Python resembles the English language and is readable for those who know English
Python is known to have a relatively smooth learning curve
Python is a broadly used and popular language
Python is increasingly good for data science
Learning Goals with Python¶
Our learning goals with Python are a little different than they might be in a straightforward Computer Science course. We’re striving to:
Learn how to use Python as a tool and apply it to cultural questions
Learn how to read and think critically about Python code
Learn how to tinker with existing Python code for our own purposes
Learn how to better collaborate with computer scientists and software developers
Python Version 3¶
The latest version of Python is Python 3. Python 2 has officially been retired. You should not use Python 2.
It’s possible that you may come across old Python 2 code on the internet, which won’t work with Python 3. A tell-tale difference between Python 3 and Python 2 code is the syntax for the
In Python 3, the
print() function requires parentheses.
print("Good riddance, Python 2!")
Good riddance, Python 2!
In Python 2, the
print() function does not parentheses.
print "Good riddance, Python 2!""
File "<ipython-input-2-479c4eb9334d>", line 1 print "Good riddance, Python 2!"" ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Good riddance, Python 2!"")?