Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

Teeing up Python - Code Golf

EuroPython Conference via YouTube

Overview

Explore the art of code golfing in Python through this 27-minute EuroPython Conference talk. Discover techniques to minimize code length while maintaining functionality and readability. Learn about default values, tuple manipulation, list comprehensions, functional programming concepts, and context managers. Gain insights into writing more Pythonic and concise code that enhances understanding for future readers. Apply these strategies to reduce cognitive load and improve code clarity in your own projects.

Syllabus

Intro
WARNING
Code Golfing
Snake Oil' Benefits
What are Strokes?
Ever written code like this?
Counting up the strokes
Visual Diff
Initializing dict values
Cleaning Up Resources
Context Managers
Exception Handling
"Simple" implementation
Let's decorate with @contextmanager
Functions aren't scary
Quick Functions Primer
Goofus and Gallant Highlights
Goofus and Gallant explore functions
Goofus and Gallant explore map
Goofus and Gallant explore reduce
Goofus and Gallant explore filters
Comprehending Comprehensions
Comprehensions Deconstructed
Better Mapping with Comprehensions
Better Filtering with Comprehensions
Better Reduces with Compressions
Better dicts with Comprehensions
Where can conciseness help?
Quick Whiteboarding Tip
Final Takeaways • Stroke reduction (making code more concise) reduces the cognitive load to understand code.

Taught by

EuroPython Conference

Reviews

Start your review of Teeing up Python - Code Golf

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.