Home - Python Bootcamp for Researchers

Constantine Lignos

Tutorials

Basics

  1. Introduction
  2. Writing your first program
  3. Basic data structures
  4. Iteration
  5. Exercises

Intermediate

  1. More on iteration
  2. Anti-patterns
  3. Classes
  4. Odds and ends
  5. Exercises

Basic data analysis

  1. Introductory notebooks

Examples

  1. CSV
  2. Introductory IPython notebooks

Examples

  1. cat: A simple version of the cat utility that concatenates files given as arguments, such as chapters one and two of Jane Austen’s Pride and Prejudice. Run:
    python cat.py pp_ch1.txt pp_ch2.txt
  2. make_wordlist: Create a frequency-sorted wordlist from a tokenized text file. Use the tokenized version of chapters 1-2 of Pride and Prejudice as input. Run:
    python make_wordlist.py pp_ch1-2_tokenized.txt > wordlist.txt
  3. totaldict: Demonstrates inheritance from a built-in class.
  4. concordance: Builds a concordance from a text file, such as the first chapter of Pride and Prejudice and report statistics for a word in it. Run:
    python concordance.py pp_ch1.txt wife

Resources

  1. Dive Into Python (Mark Pilgrim): This is by far my favorite introduction to Python, and this is how I learned Python myself. It doesn’t go much into details, but it gives you the key insights and walks you through the most important things in the language. You get the most benefit if you’ve worked with a lot of other programming languages (as he compares to them frequently), but if you haven’t this is still valuable.
  2. Non-Programmer’s Tutorial for Python 2.6 This is the best resource I’ve seen for new programmers learning Python. The examples are simple and engaging, and it’s quite easy to read.
  3. Python Tutorial: The Python Tutorial is a little dry at times, but it’s more comprehensive than Dive into Python, and since it doesn’t try as hard to dumb things down it’s a very accurate description of the language.
  4. Learning Python (Mark Lutz): While the organization of the chapters will only make sense to seasoned programmers, the content can be a bit more approachable. A good, well-rounded introduction. (This link only works on Penn’s network.)