accessibility: learning to work with huge amount of data
automate the tedious; spend more time on the fun stuff
reproducibility: do it once, do it a thousand times
flexibility: only limit on your choices is your imagination
affordability: free to run,
scale-ability: from one paragraph to a million books
transferability: convert files from one system to another
longevity: work with plain text files and .csvs will enhance the likelihood your data can still be read and processed 20, 40 years from now
A note on the programs we will use
First a note on the programs we will be using:
Python is programming language. It is:
a general language - with applicability to many fields
a high-level language - which makes it more human readable if not quite as fast as low-level languages
one of the easiest programming languages for novices to learn
popular in the field of Digital Humanities
like all programming languages, Python includes core functions and extended packages or modules. Each package or module provides additional functionality. For example, if you want to be able to process different types of dates and times you may want to use the datetime package.
Anaconda is a repository management system that allows you to manage the different packages you will need to install for Python. In this class we will use a basic version of Anaconda called Miniconda. Anaconda comes with hundreds of packages taking up 3GB of hard drive space. That is more than we will need. Instead, we will install Miniconda which just provides the management system and a few basic programs to start.
Miniconda includes Spyder a user interface for programming with Python. Python allows you to see the programs you have created, the results of those programs, and variables lists and graphs - all at the same time.
So: Python is the programming language we will use, Spyder is the interface that will allow us to interact with Python, and Miniconda is the management system that will make it easier to install and work with any additional packages we may need to use.
Anaconda vs. Miniconda
While I suggest most of you install Miniconda, if you think you might go deeper into Python programming after the class is over and you have the space on your computer to install 3 GB of programs, you may want to install the full Anaconda package.
Choose Anaconda if you:
- Are new to conda or Python
- Like the convenience of having Python and over 150 scientific packages automatically installed at once
- Have the time and disk space (a few minutes and 3 GB), and/or
- Don’t want to install each of the packages you want to use individually.
Choose Miniconda if you:
- Do not mind installing each of the packages you want to use individually.
- Do not have time or disk space to install over 150 packages at once, and/or
- Just want fast access to Python and the conda commands, and wish to sort out the other programs later.
Install Anaconda or Miniconda:
check if Python is installed
open your terminal or command line (for more info on using the terminal in Windows or Mac click on these links).
check if Python is installed, type:
##for Mac:
which python
##for Windows:
where python
##or
python --version
Open Spyder (type “which spyder” in the Mac terminal or “where spyder” in the Windows terminal to find out where it is).
Place Spyder in your start menu or taskbar so that you can easily find it next time.
Spyder in your start menu
Write your first program in Python
Create a folder on your computer where you will save all your Python work for this class. It is recommended to not use any spaces in folder names and not to bury it too deep in your computer. (i.e. “C:/Users/yourName/Documents/Python” not “C:/Users/yourName/Documents/2019/Classes/498/ComputerStuff/Python”)
In the editor window, type in the following: (link: os package)
# hashtags represent comments. These are for human eyes only. The computer will not read these.
## first import the package "os," which will allow us to move between different folders on our computers.
import os
## set the "working directory": the folder you will be using.
os.chdir([path where your folder is located]) ##i.e. "C:/Users/yourName/498/Python" (include quotes)
print("Hello World!")
Save)
Press the green arrow at the top of Spyder to run your first program. –>