Clean Code Development With Python (2023-03-28 - 2023-03-29)¶
Work Environment¶
Python Installation
IDE
Package Installation, Virtual Environments
Day 1¶
Introduction¶
Clean Code?¶
From Is Software A Craft? Software Is A Craft! ⟶ Clean Code:
Demo Hacking¶
The demo hacking session was extended through the entire session, with topics woven in as time seemed right. Read on for those.
Python Development: Select Topics¶
Knowing more about Python enables one to write … well … more code in fewer lines. While that is not usually an attitude of programmers that everybody loves, in Python there’s a word for it: Pythonic. An early PEP, “PEP 20 – The Zen of Python” describes what that could be. Lets have a closer look at what today’s version of the language offers in that respect.
Built-In Types: Facts¶
for
Loops, And The Iterator Protocol¶
Day 2: Clean Code? (Software Development: A Craft)¶
Closures, And Function Parameters¶
functools.partial
was used yesterday to augment os.listdir()
with the dirname: provide my own version, using a closure
Generators (Again), yield
Fixtures, And yield
Context Managers¶
Generator recap: Implementing A Fibonacci Number Generator
More pytest (yield-fixtures)
How come pytest provide fixtures by saying
test_blah(tmpdir)
? ⟶ inspect — Inspect live objectspytest.monkeypatch
(mockingos.listdir()
) (How to monkeypatch/mock modules and environments)
While we are at yield-fixtures: contextlib (Context Managers: The with Statement)
Object Oriented Programming¶
(Maybe begin with operator overloading?)
Untold¶
Decorators (The Ominous @
)¶
Exceptions¶
Modules And Packages¶
Pandas¶
From Pandas:
Design Patterns¶
Discussion: so what? OO is there to solve problems in a readable and reproducible way.
Pythonize some patterns (the simpler ones) from Design Patterns With C++. Maybe …
Adapter
Proxy
Composite
Observer