Appendix B — A Primer on Python

This is a very shallow introduction to the Python programming language, focusing only on the basic features of the language that we use throughout the book. This appendix does not pretend to be a full introduction to neither Python nor programming in general.

Python is a multi-paradigm, dynamically-typed programming language with strong influences from both the object-oriented and the functional paradigms. As such, Python features all the basic notions in most traditional OOP and functional languages, including classes, multiple inheritance, single-dispatch polymorphism, top-level and nested functions, lambdas, iterators, and optional support for nominal typing and some basic structural typing.

If all or some of the above sounds alien to you, just believe us: if you’ve tried any of the top 20 most popular programming languages before, learning Python will be a breeze.

That being said, this is not intended to be a complete introduction to Python. We assume you already code in some other language and are familiar with the basic notions of variable declarations, loops, function declaration and invocation, and some object-oriented programming. As such, this appendix focuses only on the syntactic and the most important semantic aspects of the Python programming language that make it different from other well-known languages such as C++ or Java.

Basic syntax

Functions

Classes

Generators and Iterators