Write Python like a professional: generators, decorators, async, tests and safe tools you can ship. Every example runs.
- 28 lessons
- 7 units
- 5 h 33 m in all
- £0, for good
what’s inside.
For people who build things on their own and want code that others trust and can change.
Python Level 3 is for people who finished Levels 1 and 2. In 28 lessons you learn the tools professionals reach for every day: comprehensions and generators, decorators, context managers, dataclasses, async code, performance thinking, argparse, mocks and safe input handling. It ends with a level check: a log analyser you ship yourself, tested on good logs, bad lines and bad options.
every lesson goes the same way.
- meet it
- guess first
- your turn
- fix it
- nailed it
unit 1
Smarter loops
Build, filter and stream data in a line or two.
- Lists in one line10 minTurn a three-line loop into one clear line that builds a new list.
- Dictionaries and sets in one line11 minReshape a dictionary or find the different values in a single line.
- What a for loop really does12 minLook inside every loop and step through items by hand.
- Generators13 minWrite functions that hand out values one at a time, only when asked.
unit 2
Functions about functions
Pass functions around, wrap them and give them a memory.
- Functions are values11 minHand a function to another function, and sort anything by anything.
- Any number of arguments12 minWrite functions that take names, defaults and as many values as you like.
- Functions that remember12 minBuild functions that carry their own private memory around.
- Decorators14 minAdd logging, checks and more to any function without touching its code.
unit 3
Shapes and clean-up
Describe your data clearly and always tidy up after yourself.
- Inside the with statement12 minSee what
withdoes for you, and build your own clean-up object. - Context managers from a generator12 minWrite set-up and clean-up as one short function instead of a class.
- Type hints11 minWrite down what each value should be, so people and tools can check.
- Dataclasses12 minDescribe a record in a few lines and get a whole working class.
unit 4
Work smarter
Use Python's toolbox, and make your code fast where it matters.
- The itertools toolbox11 minJoin, number and slice streams of data without building lists.
- Counting steps12 minJudge how much work code does, and spot the line that will slow it down.
- Choosing the right structure12 minTurn slow searches into one step, and tally or group data in a line.
- Remembering answers11 minStop a function working out the same answer twice.
unit 5
Waiting well
Wait for slow things without wasting time, and survive when they fail.
- Coroutines12 minWrite functions that pause while they wait for a slow reply.
- Doing things at the same time12 minWait for several slow replies at once instead of one after another.
- Tasks12 minStart slow work in the background and collect the result later.
- When waiting goes wrong13 minGive up on slow replies and keep going when one job fails.
unit 6
Programs and tests
Give programs a front door and options, and test them properly.
- Programs with a front door10 minMake a file that runs as a program but stays quiet when imported.
- Command-line arguments12 minLet people choose what your tool does with words like
--top 3. - Testing well13 minWrite tests that check one thing each and find bugs at the edges.
- Fakes with unittest.mock13 minTest code that pays, emails or rolls dice, without doing any of it.
unit 7
Safe and shipped
Guard your program's edges, keep secrets secret and ship a real tool.
- Checking input at the door12 minReject bad data the moment it arrives, with errors of your own.
- Secrets10 minMake tokens and codes that nobody can guess, and check them safely.
- Failing politely11 minTurn expected errors into one clear sentence and an exit code.
- Shipping a tool15 minJoin generators, dataclasses, options and polite errors into one program.