Instructional materials
- The official Python website includes a tutorial that I have linked to extensively on the schedule page of this site. I find it is more useful as a reference than a tutorial.
- Automate the Boring Stuff with Python is a solid introduction to Python 3 with only partial overlap with our material.
- Jessica Garson's Resources for Learning Python is an amazing list of resources
- The Codecademy Python course consists of lots of small, hands-on exercises
- Zed A. Shaw's Learn Python 3 The Hard Way ("The hard way is easier")
Python 3 and Anaconda
We recommend installing the free Anaconda Python distribution, which includes IPython, Numpy, Scipy, matplotlib, scikit-learn, NLTK, and many other useful packages. This is not required, but it's an easy way to get all these packages installed. Unless you're very comfortable with Python package management and like installing things, this is the option for you!
Please be sure that you download the Python 3 version, which currently installs Python 3.8. (Python 3 is not compatible with Python 2; this course will be exclusively in Python 3.)
Terminal (shell)
Mac users
- Launch Terminal.app, which is installed in Applications/Utilities.
- Move to the directory you want to work in by typing cd (with a final space) and then dragging the desired folder into the terminal window. That will enter its path, and then you just hit enter. (This can also be done while inside the Python shell, that is, after the next step.)
- Type ipython and hit enter. Now you're in the interactive shell.
- Hit Control-D to exit.
Windows users
- Find Anaconda Prompt via the Start menu.
- In the window, type ipython and hit enter.
- Type ipython and hit enter. Now you're in the interactive shell.
- Move to the directory you want to work in by typing cd (with a final space) and then dragging the desired folder into the terminal window. That will enter its path, and then you just hit enter.
- Hit CTRL-Z to exit.
A course virtual environment
One you have Anaconda installed, it makes sense to create a virtual environment for the course. In a terminal, run
conda create -n pfl python=3.8 anaconda
to create an environment called pfl.
Then, to enter the environment, run
conda activate pfl
To leave it, you can just close the window, or run
conda deactivate
This page has more detailed instructions on managing virtual environments with Anaconda.
Text editors
A text editor is a program that allows you to type and save plain text (sequences of characters). Programs like MS Word, TextEdit or Notepad are not text editors, because they encode their files in special formats, which allow them to record styles and formatting.
If you don't already have a text editor you like, then I urge you to use Atom and install its script package so that you can run Python modules directly from its text editor window.
Here are a few other options, but I suggest choosing one of these only if you have independent and compelling reasons to do so. I myself can help with Atom, but I am not sure about the others.
- One favorite these days is Sublime Text. It runs on macOS, Windows, Ubuntu. It's not really free but you can get by using it for free if you can stand the guilt.
- Old school programmers usually use either emacs or vim (an updated version of vi) – both free. A friendly version of emacs for macOS is called Aquamacs.
- People who have been using Macs since the 1990s often like TextWrangler.
- For Windows, the free Komodo Edit seems to have a good reputation.
- You may well want to move on to an IDE (Integrated Development Environment) at some point. PyCharm is a great free one.