Python for Programmers

Programming languages

This three day course is designed for developers with experience of other languages who need to get up to speed on Python. At the end of this course the students will know the essentials of the Python language, how to use Python's module system to structure code, and how to approach the development of Python programs. The class will focus on Python 3, unless Python 2 is specifically requested.

Rather than working bottom-up, this course starts with analyzing and understanding working examples. This way developers will understand the various interdependent techniques in situ rather than in isolation.

  • We start immediately with working programs.
  • Testing is integral to our approach.

Expect to get your hands dirty! We work with realistic examples that help you gain knowledge and practice techniques applicable to building substantive applications. You'll be writing code with tests under plausible constraints.

  • We encourage maintainability over cleverness.
  • Course leaders have over a decade of experience.

Outline:

Day 1 – Getting Started

  • Setting up your Python environment
  • Writing and running your first Python program
  • The REPL
  • Significant whitespace
  • Python culture
  • Importing modules from the standard library
  • Scalar types: int, float, None, and bool
  • Relational operators
  • Conditional statements
  • While loops and for loops
  • Strings and bytes objects
  • The basics of lists and dictionaries
  • Creating, running, and importing modules
  • Defining functions and return values
  • Distinguishing module import and module execution
  • The Python execution model
  • Main functions and command line arguments

Day 2 – Fundamentals

  • Argument passing and function arguments in detail
  • Python's type system
  • Variable scoping
  • Everything is an object
  • Common collections: tuple, string, range, and list
  • Shallow copies
  • Growing, sorting, repeating, and reversing lists
  • Dictionaries and sets
  • Collection protocols
  • Exceptions: try, except, raise, and finally
  • Exceptions in APIs and protocols
  • Platform-specific code
  • List, set, and dictionary comprehensions
  • Generator expressions
  • Iteration protocols
  • Generators, lazy evaluation, and infinite sequences

Day 3 – Object Orientation

  • Defining classes
  • Instance methods, initializers, and implementation details
  • OO With function objects
  • Polymorphism and duck typing
  • Inheritance and implementation sharing
  • Reading, writing, and appending to text and binary les
  • Context managers and with-blocks
  • Bitwise Operators
  • Testing with the unittest module
  • Debugging with PDB
  • Virtual environments
  • Distributing your programs
  • Installing third-party modules

Tid

09:00 - 16:15

Emner

• Built-in types and the Python object model

• Flow control and exceptions

• Class definition, inheritance, and common usage patterns

• Program organisation with modules and packages

• The Python standard library

• Obtaining and installing Python packages

• Comprehensions, generators, and iteration

• Serialization, unit testing, and filesystem interaction

• Debugging

Tilleggsinfo

Computer Setup:

This workshop requires that you bring a laptop with the following software installed:

  • Python 3.3 or greater installed. Python 3.5.1 would be ideal. https://www.python.org/downloads/
  • An editor for Python code. Attendees can use whatever editor they prefer, but we recommend PyCharm which is a full-featured Python IDE : https://www.jetbrains.com/pycharm/
  • The ability to either connect to the Internet or accept USB flash drives so we can distribute course materials on the day.