Ned Batchelder
banner
nedbat.com
Ned Batchelder
@nedbat.com
Python, Boston, mathy fun, juggling, autism parenting. https://nedbat.com
I'm writing letters to defend democracy, how are you spending your day? votefwd.org
October 25, 2025 at 5:13 PM
Every puzzle contains another puzzle: how was it constructed? The game Flow Free asks you to find the paths to connect same-colored dots on a grid. How are these layouts created?
August 7, 2025 at 5:08 PM
Want a concise daily digest of issue and pull request activity from your GitHub repos? Try Dinghy: pypi.org/project/ding...
April 2, 2025 at 2:44 PM
My watchgha lets you watch the progress of GitHub Actions in your terminal. Now the job names are sorted, since GitHub now returns them in a randomish order.

github.com/nedbat/watch...
March 25, 2025 at 6:41 PM
In #Python, @classmethod can used to create alternate constructors for making objects in other ways. Here's a simple example:
January 18, 2025 at 6:10 PM
Comparison operators in #Python can be chained together, but using them that way could be controversial. I wrote this this other day:
January 13, 2025 at 1:49 PM
Years ago, I tried ads on my site. My business card cube page got some attention, so I had $200 revenue for the year. When my tax guy saw that, he said, "Why don't you just make 1000 sites?" He was ahead of his time...

nedbatchelder.com/text/cardcub...
January 9, 2025 at 11:18 PM
Wow, Apple somehow added a notification with a circle-x close button that literally does not work, and the thing appears on every video call:
January 8, 2025 at 10:37 PM
Happy #Python New Year!
December 31, 2024 at 6:23 PM
Is this #Python too compact? Perhaps, but there could be useful things to learn. Full explanation unpacked at nedbatchelder.com/blog/201802/...
December 12, 2024 at 11:49 AM
After I posted, I saw that the browser has to be nearly full-width on my laptop for it to display.
December 11, 2024 at 3:38 AM
Splitting a string once in #Python: .split() has maxsplit=, but .partition() can be better:
December 6, 2024 at 4:40 PM
I got a lot of replies with suggestions, so here are more #Python expressions to check if a (possibly empty) string has only 0's and 1's in it:
December 4, 2024 at 12:30 PM
You can write short powerful #Python expressions using its many tools. Are there other ways to check if a string contains only "0" or "1"?
December 1, 2024 at 4:02 PM
Are you using #Python 3.11 yet? It's been out for two years! Maybe this will entice you: better error messages!
November 26, 2024 at 6:33 PM
Classes in #Python can define their own formatting mini-languages for f-strings by defining __format__. Full details: nedbatchelder.com/blog/202204/...
November 24, 2024 at 7:14 PM
But "charging" is still black/white with a symbol. Why take yellow from iPhone and not the rest of the design (green for charging)? This just seems dumb.
November 23, 2024 at 3:06 PM
Who at Apple thought low-power mode in Sequoia should be represented by yellow in the all-monochrome menu bar? Yellow means low power (a good thing)? Yellow on white? wtf?
November 23, 2024 at 1:30 PM
What if you want space around the word before centering? Is #Python letting me take this too far? Nested f-strings!?
November 22, 2024 at 5:14 PM
Also: you can also use variables (or expressions?!) for the formatting information! #Python is cool...
More details and explanation at fstring.help
November 21, 2024 at 5:50 PM
String formatting in #Python lets you left-, right-, or center-justify a value. You can specify the fill character to use. The syntax is colon, fill-char, <^>, width:
November 21, 2024 at 11:12 AM
For loops in #Python can assign to more than just plain names. Any assignment target is allowed:
November 17, 2024 at 12:04 PM
#Python primitives are powerful tools that can combine to get a lot done with just a little code. The dict() constructor can make a dict from key/value pairs:
November 11, 2024 at 4:39 PM
Nested loops can sometimes be replaced by one itertools.product() from the #Python stdlib:
November 4, 2024 at 6:14 PM
In #Python, dicts can have tuples as keys. Consider a dict with (x,y) keys instead of nested lists for a grid. It simplifies sparse grids, "resizes" are automatic, it doesn't matter where (0,0) is, and you can use negative positions:
October 29, 2024 at 12:45 PM