liveBook · Manning

Operator module

The operator module is a Python standard-library module providing function forms of built-in operators and related operations.

How 2 Manning books explain it

Python Workout: 50 ten-minute exercises

The operator module is a Python standard-library module providing function equivalents for many built-in operators.

How it is used
Uses operator functions to replace branching with dispatch tables and to provide reusable key functions for sorting.
How deep it goes
Works through calculator dispatch and itemgetter usage, but does not enumerate the module’s full API.
Examples
Demonstrates a prefix arithmetic calculator and sorting dictionaries by last name and first name.
What you can do after
Apply it via Python’s standard library to build dispatch tables and concise sorting key functions.

Read how Python Workout: 50 ten-minute exercises explains operator module →

Python Workout, Second Edition

The operator module is a Python standard-library module that provides function forms of built-in operators and related operations.

How it is used
Deploys function-valued operations for sorting data and selecting calculations from symbolic input.
How deep it goes
Explains itemgetter construction, multi-key sorting, dispatch-table lookup, unpacking, and maxsplit, but not module-wide API coverage.
Examples
Uses country dictionaries, sorted people records, tuple and string indexing, and a calculator dispatch table.
What you can do after
Apply it via itemgetter and operator-function dictionaries to write concise sorting keys and dispatch-driven calculations.

Read how Python Workout, Second Edition explains operator module →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.