#pythonbestpractices

Python PeakPythonPeak
2026-02-12

What's wrong with this Python request context?

What's wrong with this Python request context in a logging pipeline. The Python function uses a mutable default list, so requests share the same trace buffer. In Python APIs this mixes user data and breaks audits.

...

youtube.com/watch?v=-ERw7BFPy1o

Python PeakPythonPeak
2026-02-11

Why is this Python price rounding wrong?

Why is this Python price rounding wrong in billing. The Python code builds Decimal from a float, so binary precision leaks into money math. In Python finance this creates off by cents totals.

...

youtube.com/watch?v=wrkMRPbp91g

Python PeakPythonPeak
2026-02-06

Why does this Python cache mutate itself?

Why does this Python cache mutate itself between requests. The Python code caches a list and returns it directly, so callers mutate shared cached state. In Python services this causes ghost data in responses.

...

youtube.com/watch?v=m8EkmbfHcEw

Python PeakPythonPeak
2026-01-30

What's wrong with this Python cache refresh?

What's wrong with this Python cache refresh under load. The Python code lets every request recompute the value when it expires, causing a stampede. In Python services this melts the database.

...

youtube.com/watch?v=EAnLdUclDwo

Python PeakPythonPeak
2026-01-25

What's wrong with this Python database loop?

What's wrong with this Python database loop in an API endpoint. The Python code queries once per item, creating an N plus one pattern. In Python services this kills latency and database load.

...

youtube.com/watch?v=N6sw4QnOV00

Python PeakPythonPeak
2026-01-24

Why does this Python worker drop messages?

Why does this Python worker drop messages in production. The Python code acknowledges the queue before the database commit, so failures lose data permanently. In Python pipelines this creates silent gaps.

...

youtube.com/watch?v=SAcVyYDFUF0

Python PeakPythonPeak
2026-01-24

Why is this Python command injection possible?

Why is this Python command injection possible in a media service. The Python code builds a shell command with user input and runs it with shell=True. In Python backends this allows attackers to execute commands.

...

youtube.com/watch?v=4Bkzc5ZVrxE

Python PeakPythonPeak
2026-01-22

What's wrong with this Python asyncio gather?

What's wrong with this Python asyncio gather in a fan-out call. The Python code lets one failure cancel all other tasks, so partial writes never finish. In Python services this causes missing records and inconsistent state.

...

youtube.com/watch?v=sDLObQv7Luc

Python PeakPythonPeak
2026-01-21

What's wrong with this Python account transfer?

What's wrong with this Python account transfer in production. The Python code updates two balances without a transaction, so crashes leave money missing or duplicated. In Python finance services this creates inconsistent ledgers.

...

youtube.com/watch?v=xoGIKrtHHt8

Python PeakPythonPeak
2026-01-20

Why is this Python cache a security risk?

Why is this Python cache a security risk in production. The Python code unpickles data from a client controlled source, which can execute arbitrary code. In Python services this is a remote code execution vulnerability.

...

youtube.com/watch?v=ZTCtqjdlANk

Python PeakPythonPeak
2026-01-12

Why does this Python cache serve the wrong language?

Why does this Python cache serve the wrong language in production. The Python code caches responses without locale in the key, so users see another language. In Python APIs this becomes a localization incident.

...

youtube.com/watch?v=YA1sMwee9Z4

@sybren Preach! 🙌 Bare except: clauses are a recipe for disaster, and can make debugging a nightmare. 🐜
Thanks for sharing this important tip with the community! 👏 #PythonBestPractices #ErrorHandling #Debugging

2024-07-07

Modern Good Practices for Python Development

An outline of best practices for #Python development, including using tools like #pyenv, #pipx or Development Containers for managing Python versions. It also recommends using pyproject.toml for project configuration, virtual environments for package management, and tools like Black, #Ruff, and #pytest for code formatting, linting, and testing.

#PythonBestPractices #PythonDevelopment #PythonTools #PythonProgramming

stuartellis.name/articles/pyth

A computer screen with Python code
2024-01-26

Hey #python developers. How do you keep your docstrings DRY? When I find myself copying same part of a docstring to 7 places after introducing a new parameter I wonder if it could be made somehow better 🤔

#pythonbestpractices

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst