Ever had a Python function behave strangely, remembering values between calls when it shouldn’t? You’re not alone! This is one of Python’s sneakiest pitfalls—mutable default parameters. Recently someone asked for help in our Pybites Circle Community with a Bite exercise that seemed to be behaving unexpectedly. It turned out that this was a result of modifying a mutable parameter… Continue reading The Mutable Trap: Avoiding Unintended Side Effects in Python
Articles on debugging
Stuck in import hell? Walk your way out.
By Russell Helmstedter on 22 February 2024
Welcome to Hell Cue the theme song from The Fresh Prince of Bel Air. This is a story that turns out well. But my code got stuck in import hell. I tried to teach my students all about pytest. Instead, for two days, I was sent on a debugging quest. I teach middle school students… Continue reading Stuck in import hell? Walk your way out.
Write more maintainable Python code, avoid these 15 code smells
By PyBites Team on 15 September 2023
This week we talk about code smells. 💡 Listen here: Also available on our YouTube channel: Code smells are characteristics in the code that might indicate deeper issues or potential problems. While they’re not necessarily bugs, they can be a sign of poor code quality or maintainability issues. 😱 We distilled 15 common smells ranging… Continue reading Write more maintainable Python code, avoid these 15 code smells
⚠️Why you should avoid import * in Python 🐍
By Bob Belderbos on 15 August 2023
Anyone who’s worked with Python knows that modules can be a Godsend, saving you time, effort, and many lines of code. They even have namespacing built-in 💪 😍 To expand on this a bit: However, not all ways of using modules are equally beneficial. In this article, we will discuss why using import * can… Continue reading ⚠️Why you should avoid import * in Python 🐍
11 Planning and Productivity tips for Python developers
By PyBites Team on 23 June 2023
This week we talk with Sambhavi Dhanabalan about productivity as a developer. She shares 11 tips from her experience: 3 around planning and 8 generic tips. Watch here: Or listen here: We also talk about her background, wins and a book she’s reading. Enjoy this insightful conversation with Sambhavi. We’re sure that if you follow… Continue reading 11 Planning and Productivity tips for Python developers
Django Plugin Recommendations by Antonio Melé | Top 10 Picks for Web Development
By PyBites Team on 7 May 2023
Watch here: Or listen here: He’s back! Django by Example book author Antonio Melé 😍 Not only that, we did this interview in person at a cafeteria on the beach 🏖 In this episode he shares his 10 favorite Django plugins 💪 💡 1. Django Debug Toolbar 2. Django REST Framework 3. Django Channels 4. Django Celery 5. Django Extensions… Continue reading Django Plugin Recommendations by Antonio Melé | Top 10 Picks for Web Development
It’s not you – it’s me
By Ian Pritchard on 9 January 2023
Every so often I get convinced that a challenge test suite is wrong or Python is somehow giving me the wrong results. “It’s You”! I checked and quadruple-checked my code. I walked through every single line in the IDE debug mode noting how the variables changed as the code branched through. I printed everything printable… Continue reading It’s not you – it’s me
Help, I need to refactor a mega class! Here are 5 tips …
By PyBites Team on 24 September 2022
Somebody asked the other day for tips on how to refactor a mega-class? It was actually one of the first tasks on the new job, ouch! A single class, several thousands lines of code, no tests available 😮 You might scratch your head and say WTF?! After all, good developers decouple code into manageable pieces… Continue reading Help, I need to refactor a mega class! Here are 5 tips …
A debugging tale
By Bob Belderbos on 6 March 2022
I ran into an interesting issue debugging the other day … I used isort with pre-commit to automatically sort imports before committing my code. This is a huge time saver and I am very thankful for both tools, as well as black and flake8. They save a ton of time and they instantly boost the… Continue reading A debugging tale
10 Cool Pytest Tips You Might Not Know About
By Bob Belderbos on 26 February 2021
Here are 10 things we learned writing pytest code that might come in handy.