The game has changed. With AI handling more routine coding tasks, the developers who will lead the future are the ones who can transcend their traditional role.
The game has changed. With AI handling more routine coding tasks, the developers who will lead the future are the ones who can transcend their traditional role.
Here's a neat way to get the characters that appear in every group 👇
`set.intersection(*...)` returns the items that exist in all given sets. It can take multiple sets as args, which we "splat" (`*`) unpack from a gen expression.
Here's a neat way to get the characters that appear in every group 👇
`set.intersection(*...)` returns the items that exist in all given sets. It can take multiple sets as args, which we "splat" (`*`) unpack from a gen expression.
>>> from operator import mul
>>> from functools import reduce
>>> reduce(mul, [1, 2, 3, 4])
24
Turns out that since 3.8 the math module has `prod` ->
>>> from math import prod
>>> prod([1, 2, 3, 4])
24
>>> from operator import mul
>>> from functools import reduce
>>> reduce(mul, [1, 2, 3, 4])
24
Turns out that since 3.8 the math module has `prod` ->
>>> from math import prod
>>> prod([1, 2, 3, 4])
24
It's a wrapper around a script I made the other day to benchmark code quality ->
It's a wrapper around a script I made the other day to benchmark code quality ->
I only needed the worst N files / most complex N functions…
but the code was doing a full sort and then [:top_n].
I only needed the worst N files / most complex N functions…
but the code was doing a full sort and then [:top_n].
`case 1 | 2` groups opcodes that share behavior
`case 5 if part2` keeps the extra condition right next to the logic ("flat is better than nested")
Feels more like a clean dispatcher than a pile of conditionals.
`case 1 | 2` groups opcodes that share behavior
`case 5 if part2` keeps the extra condition right next to the logic ("flat is better than nested")
Feels more like a clean dispatcher than a pile of conditionals.
✅ Works with any iterable.
✅ Handles a smaller final chunk automatically.
✅ Use `strict=True` (Python 3.13+) to raise a `ValueError` when the final batch isn’t full.
✅ Works with any iterable.
✅ Handles a smaller final chunk automatically.
✅ Use `strict=True` (Python 3.13+) to raise a `ValueError` when the final batch isn’t full.
In a recent @Pybites code ensemble session we tackled an Advent of Code puzzle where you repeatedly “react” a polymer string by removing adjacent units like aA / Bb.
In a recent @Pybites code ensemble session we tackled an Advent of Code puzzle where you repeatedly “react” a polymer string by removing adjacent units like aA / Bb.
With `removeprefix("$")` and `removesuffix(suffix)` you strip only what you *expect* to be there, then `float(cap) * multiplier` does the rest.
Classic EAFP: try to parse, fall back to `0.0` when the data is junk.
With `removeprefix("$")` and `removesuffix(suffix)` you strip only what you *expect* to be there, then `float(cap) * multiplier` does the rest.
Classic EAFP: try to parse, fall back to `0.0` when the data is junk.
Django bulk_update memory issue
blog.pecar.me/django-bulk...
Logging memory usage in #Python using `psutil` - example below 👇
Bonus: comparing list comp vs gen expression 🐍 😍 📈
Django bulk_update memory issue
blog.pecar.me/django-bulk...
Logging memory usage in #Python using `psutil` - example below 👇
Bonus: comparing list comp vs gen expression 🐍 😍 📈
Instead of selling you "content," we're discounting "accountability."
For the first time, we've slashed the price on our #Python Snipster (Intermediate) and Foundations (Beginner) cohorts (30-35% off).
Instead of selling you "content," we're discounting "accountability."
For the first time, we've slashed the price on our #Python Snipster (Intermediate) and Foundations (Beginner) cohorts (30-35% off).
Context: I was solving an AoC which required a valid password to have a digit that appeared in a run of exactly two (not part of 111 or 2222, etc).
Context: I was solving an AoC which required a valid password to have a digit that appeared in a run of exactly two (not part of 111 or 2222, etc).
It explains concepts really well by using easy to understand analogies, for example around ownership and borrowing, which can be hard to grasp at first. 💡
It explains concepts really well by using easy to understand analogies, for example around ownership and borrowing, which can be hard to grasp at first. 💡
For a long time I ran Ruff (linter and formatter) via pre-commit, which is great… but I kept getting slightly annoyed at how often I’d:
For a long time I ran Ruff (linter and formatter) via pre-commit, which is great… but I kept getting slightly annoyed at how often I’d:
Two ways:
- uv tree --package six --invert → quick “who depends on this?” from uv.lock
- uv pip tree --package six --invert --show-version-specifiers → more pipdeptree-style, constraint-aware view from the actual env
Two ways:
- uv tree --package six --invert → quick “who depends on this?” from uv.lock
- uv pip tree --package six --invert --show-version-specifiers → more pipdeptree-style, constraint-aware view from the actual env
- take an AoC, solve it in Python (no AI)
- now you have a spec + approach
- rewrite in target lang (use AI tools to help debug + explain things)
This easily led to >=3 learning moments today I can now write about 💡
- take an AoC, solve it in Python (no AI)
- now you have a spec + approach
- rewrite in target lang (use AI tools to help debug + explain things)
This easily led to >=3 learning moments today I can now write about 💡
Have you tried Marimo yet?
It fixes a lot of classic Jupyter pains: hidden state, brittle execution order, and notebooks that are hard to reuse.
Have you tried Marimo yet?
It fixes a lot of classic Jupyter pains: hidden state, brittle execution order, and notebooks that are hard to reuse.
It's one of our open source libraries called `pybites-search`
Easy to run (alias) using uvx:
It's one of our open source libraries called `pybites-search`
Easy to run (alias) using uvx:
Here `issubset` reads as:
"Are all required checks contained in what’s done?"
Here `issubset` reads as:
"Are all required checks contained in what’s done?"
Had a super cool ensemble coding session today solving the “Analyze stock data” Bite. 🚀
It was a great reminder of how far you can refactor a function by leaning on built-ins 🐍
Here’s how our final function evolved:
Had a super cool ensemble coding session today solving the “Analyze stock data” Bite. 🚀
It was a great reminder of how far you can refactor a function by leaning on built-ins 🐍
Here’s how our final function evolved: