Learning Python in 2021: What a German Textbook Reveals About Teaching Code

The Shape of a Pre-Modern Onboarding

Pick up a copy of Michael Weigend’s Python 3 Schnelleinstieg (mitp Verlag, 2021) and you hold a time capsule. The cover promises proficiency in fourteen days. The interior delivers a complete CS1 progression – interpreter basics through agile practices and test-driven development – in a single German-language volume designed for absolute beginners. There is no virtual environment setup, no pyproject.toml, no type hints, no async/await. The standard development environment is IDLE. The package manager pip is mentioned but never demonstrated in a project workflow. For a learner in 2021, this was a coherent entry point. For a learner today, it is a map of a territory that has shifted.

The book’s central bet is that programming concepts stick when a novice types, runs, and incrementally extends concrete scripts: a cylinder-volume calculator, a vocabulary trainer, a GUI motivator that serves random aphorisms, a digital notebook with search and expiration. The pedagogical arc follows the classic sequence – types, control flow, functions, modules, collections, file I/O, text processing, GUIs with tkinter, graphics with Pillow, debugging, profiling, object-oriented design, and a final capstone that separates model from view. Each chapter embeds checkpoint questions and starred exercises with downloadable solutions. The approach builds confidence through immediate executability. It also encodes assumptions about Python that have since expired.

Where the Mental Models Hold

Several of the book’s explanatory choices remain sound. Variables are introduced through the “label” metaphor – names bound to objects – rather than the “container” metaphor. This fidelity to Python’s name-to-object binding pays off when the text later demonstrates chained assignment (x = y = 1) binding both names to the same object, and tuple unpacking (x, y = y, x) swapping values without a temporary. The distinction between immutable types (str, tuple) and mutable ones (list, set, dict) is linked to modeling intent: fixed-structure records versus dynamic collections.

Truthiness is presented as a deliberate design choice: empty collections and zero are false; non-empty and non-zero are true. The author illustrates the edge case cleanly – bool(str([])) is True because str([]) yields ‘[]’, a non-empty string. Comparison chaining (5 < x < 10) is explained as syntactic sugar for (5 < x) and (x < 10) with single evaluation of x, a Python-specific convenience contrasted with C and Java. range is correctly identified as a lazy iterable; list() materializes it. Set iteration order is explicitly called non-deterministic. These are not beginner simplifications – they are accurate mental models that survive contact with production code.

The Project Spine: EVA and Incremental Growth

Early scripts follow the EVA spine – Input, Processing, Output (Eingabe, Verarbeitung, Ausgabe). input() always returns str, requiring explicit float or int casting. Nested calls like float(input(…)) evaluate inside-out. The author classifies errors into syntax (pre-execution), runtime (ZeroDivisionError, ValueError on bad casts), and semantic (wrong logic, no crash). try/except is deferred until the GUI chapters, which means early scripts crash visibly – a feature, not a bug, for learning to read tracebacks.

Function abstraction arrives with defaults and keyword arguments: def fallhöhe(t: float, g: float = 9.81) -> float: demonstrates optional parameters, type annotations described as decorative, and keyword flexibility (fallhöhe(g=1.62, t=3)). Procedures (side effects) and functions (return values) are distinguished. The module system is taught as namespace management: import math versus from math import sqrt versus import math as m, with if __name__ == ‘__main__’: guarding test code. The first import creates __pycache__, noted as CPython bytecode.

Collections as Modeling Primitives

The book treats collections as the primary modeling tools. Tuples for fixed records (dates, contacts); lists for variable collections. A list of tuples becomes an inventory. Tuple unpacking in for loops (for artikel, preis in warenbestand) and list comprehensions as set-builder notation appear early. Lexicographic sort follows Unicode code points – uppercase before lowercase – a detail that bites beginners in real data. Dictionaries are introduced as hash tables with O(1) average lookup; keys must be immutable. The author simplifies hashing as “memory address directly from key literal,” omitting collision resolution. Phone numbers are stored as strings to preserve leading zeros – a practical lesson in data fidelity.

Persistence, Text, and the pickle Problem

File I/O uses open(file, mode, encoding) returning text or binary streams. pickle.dump/load serializes arbitrary objects. Append mode (‘a’) serves logs. The with statement is absent; no warning appears about pickle’s arbitrary-code-execution risk on load. Text processing follows a pipeline: lowercase, punctuation replacement, split(), set for unique words (Goethe’s Faust: 30,779 total, 6,425 unique). Regular expressions (re.findall) are characterized as “more elegant” but brittle versus proper HTML parsing. str.format with named placeholders handles templates.

GUI Programming: Event Loops and Their Hazards

The tkinter chapters reveal the event-driven model: Tk root, widgets, pack() layout, callbacks via command. .pyw suppresses the console on Windows. Entry/Text for I/O; Radiobutton + StringVar for mutually exclusive choices. A calculator example uses eval() on user input without a security caveat. The text then demonstrates a classic concurrency hazard: time.sleep in a callback blocks the main loop, freezing the UI. The fix shown uses _thread.start_new_thread (low-level, mandatory empty tuple). A marginal note correctly flags tkinter as not thread-safe and threading.Thread as preferred – yet the example remains in the text.

Image handling bridges native PhotoImage (PNG, GIF, PGM, PPM only) and Pillow’s ImageTk.PhotoImage for JPEG. A global reference is required to prevent garbage collection of the image object – a subtle lifetime issue that surprises every GUI beginner.

Debugging, Profiling, and Algorithmic Honesty

The debugging taxonomy separates syntax and runtime errors (interpreter-caught) from semantic errors (manual). Assertions (assert type(x) in [int, float]) make preconditions explicit but vanish with the -O flag. An IDLE debugger walkthrough (Step, Go, Breakpoints) lacks conditional or remote features. Profiling uses profile under the __main__ guard. The quicksort implementation creates new lists at each recursion – O(n log n) space – making it unsuitable for large data. Average-case complexity is not discussed. Empirical timings for straight selection sort (O(n²)) versus quicksort (O(n log n)) are presented as single-run, machine-dependent observations; cProfile and timeit are not introduced.

Object-Oriented Design as Structural Decomposition

Classes define attributes (state) and methods (behavior); self is convention. UML class diagrams precede code. Class attributes (wechselkurs dict) are shared across instances. Geld.add() returns a new Geld instance (immutable style) converted to the left operand’s currency. Magic methods __add__, __str__ enable + and print(). Inheritance: Zahlung extends Geld with a timestamp, overrides __init__/__str__; Zahlung + Geld returns Geld (base class) because __add__ constructs Geld – a Liskov substitution intuition violation that the text does not flag.

Agile, TDD, and the Capstone Architecture

The final chapters contrast sequential phases (Waterfall) for experienced teams on familiar work with agile (XP) for learning during development. Practices include stories, short iterations (runnable increments), pair programming, TDD, refactoring. The author acknowledges this as a methodological claim, not an empirical universal, and notes pair programming rejection due to interpersonal friction. TDD arrives via doctest: example calls with expected results embedded in docstrings, run via doctest.testmod(verbose=True). The author notes doctest suits pure functions, not GUI or I/O-heavy code.

The digital notebook capstone demonstrates clean architecture. Iteration 1: tkinter skeleton with stubs. Iteration 2: pickle persistence, search, load. Refactoring: s → notizen, docstrings, hard-coded ‘notes.dat’, separate UI/data modules (notizbuch.py, notizen_3.py). Stories add case-insensitive search (.lower()) and expiration (epoch seconds + 2-day LEBENSDAUER filter on load). The model/GUI separation enables parallel development – a pattern scalable beyond the toy scope.

What the 2021 Snapshot Misses

The limitations are structural. No complex, bytes, frozenset, or custom classes in the type hierarchy diagram. Float precision artifacts (0.1 + 0.2 != 0.3) unaddressed. Dict insertion-order guarantee (3.7+) described as “no particular order.” Mutable/immutable side-effects – aliasing via x = y = [] – not discussed, though critical for assignment understanding. Bare except: clauses suppress tracebacks. eval() in the calculator without warning. random noted as pseudo-random but used in contexts implying unpredictability. No with statement for file handles. No encoding detection guidance. Windows backslash escaping unaddressed. HTTP webcam unencrypted, no error handling. _thread.start_new_thread used for GUI offloading despite the thread-safety warning. Quicksort’s O(n log n) space unexamined. Geld lacks __repr__, operator overloading until late, KeyError handling for missing currencies. Toy agile iterations (minutes/hours) don’t reflect real coordination overhead. pickle lacks schema migration (__setstate__ absent). Global LEBENSDAUER couples expiration policy to module. Section 8.3.3 cuts off mid-sentence on error handling. Volume example uses m² for volume (likely typo for m³). Capstone exercise demands “high technical quality” without defining framework, persistence, testing, or acceptance criteria.

Reading It Today

A modern learner can still extract value from this book – but only with a supplement layer. Work through the scripts in VS Code or PyCharm, not IDLE. Create a virtual environment before the first import. Add type hints to every function signature; run mypy in strict mode. Replace pickle with json or sqlite3 for persistence. Swap eval() for a safe expression parser. Use threading.Thread with a queue for background work, never _thread. Write pytest tests instead of doctest. Format with black, lint with ruff. The core mental models – labels not containers, truthiness as convention, lazy iterables, hash-table dictionaries, event-loop GUI – remain valid. The toolchain around them has not. The book’s greatest utility today may be as a controlled environment for practicing modernization: take a working 2021 script and make it 2024-ready without changing its behavior. That refactoring exercise teaches more about professional Python than any single chapter.

Leave a Reply