Trey Hunner
banner
trey.io
Trey Hunner
@trey.io
Python & Django team trainer

I help folks sharpen their Python skills with https://PythonMorsels.com 🐍🍪

YIMBY. 95% vegan.
It's interesting that Python 2 ingrained "print statement" into our collective vocabular so deeply that the phrase is still widely used even though print hasn't been a statement since Python 2.
November 10, 2025 at 11:45 PM
If you're starting a new project and you need to generate UUIDs, I'd recommend taking a look at uuid7 Read more ‘‰ https://trey.io/flfwr9 #Python
trey.io
November 10, 2025 at 7:19 PM
I added support for paragraph-based navigation (moving between groups of consecutive non-blank lines) to pyrepl-hacks and also documented the fact that the #Python REPL supports block-based navigation via the previous-history and next-history commands.

github.com/treyhunner/p...
GitHub - treyhunner/pyrepl-hacks: Hacky extensions and helper functions for the new Python REPL.
Hacky extensions and helper functions for the new Python REPL. - treyhunner/pyrepl-hacks
github.com
November 10, 2025 at 7:04 PM
Reposted by Trey Hunner
My PyBay talk recording is up!
“Just because AI can write your tests… should it?”

youtu.be/Lha1741iEjE

It starts with a tangent about honeybees vs native bees, but I swear, I found a way to relate that topic to the talk.

Enjoy! 🐝
Just because AI can write your tests - should it? — Pamela Fox (PyBay 2025)
YouTube video by SF Python
youtu.be
November 9, 2025 at 3:20 PM
As Chris & Chris note, I *do* LOVE the Python REPL.

If you're in the Python REPL often, play with pyrepl-hacks and let me know what you think.

I'd also love to hear if you have ideas for more commands (or features) to add.

Post: treyhunner.com/2025/10/hand...

Project: github.com/treyhunner/p...
November 7, 2025 at 10:11 PM
I usually prefer to reach for f-strings when formatting datetime objects because it's a bit shorter than the alternative. Read more ‘‰ https://trey.io/l4b84k #Python
November 7, 2025 at 7:19 PM
Whenever I see nested loops in a comprehension, I think "flattening". Read more ‘‰ https://trey.io/aeo9fg #Python
November 7, 2025 at 1:26 AM
Throwing some financial support toward @python.org? Excellent!

If you are a #Django user, consider also supporting the DSF.

The Django Software Foundation has been running a fundraiser for the past couple weeks. It ends it 5 days.
November 5, 2025 at 10:16 PM
If you don't maintain a library where your users would benefit from delayed string interpolation or automatic pre-processing of inputs, then you don't need to think about t-strings until a library tells you to use one. Read more ‘‰ https://trey.io/n4mlgb #Python
November 5, 2025 at 2:21 AM
Most #Python classes use a dictionary (__dict__) to store their attributes.

Some classes use a more memory efficient mechanism for attribute storage.

More in my new screecast on __slots__ 👇
Using __slots__ for optimizing classes in Python
YouTube video by Python Morsels
youtu.be
November 4, 2025 at 10:09 PM
(not so fun) fact 💡

Whether $2 per gallon or $4 per gallon, 1 gallon of milk has a carbon footprint and water usage footprint of ~15,000 Chat GPT prompts.
So far, this investigative journalism piece has 100% satisfaction in the comments. 🥛 🐄 You should check it out with this friendly @racketmn.com gift link. If you like what you read, please become a Racket member for more great local alt weekly content! racketmn.com/its-all-the-...
It's All the Same Milk! - Racket
A gallon of whole milk can cost anywhere from $2.16 to $4.95. Why?
racketmn.com
November 4, 2025 at 5:32 AM
Python SC accepted PEP 798

PEP: peps.python.org/pep-0798/

Acceptance: discuss.python.org/t/pep-798-un...

So this:
[*row for row in list_of_lists]

Will do the same thing as this:
[x for row in list_of_lists for x in row]
PEP 798 – Unpacking in Comprehensions | peps.python.org
This PEP proposes extending list, set, and dictionary comprehensions, as well as generator expressions, to allow unpacking notation (* and **) at the start of the expression, providing a concise way o...
peps.python.org
November 3, 2025 at 9:01 PM
Python 3.15 will include lazy imports, but it won't allow this:

lazy from module import *
November 3, 2025 at 8:37 PM
I sometimes say "stir pea time" because it hints that there are three separate parts to that name. Read more ‘‰ https://trey.io/l4b84k #Python
November 3, 2025 at 7:19 PM
Reposted by Trey Hunner
Wooo, unanimous acceptance of 810!

Python is getting lazy imports!

So excited about this!

discuss.python.org/t/pep-810-ex...
PEP 810: Explicit lazy imports
Dear PEP 810 authors. The Steering Council is happy to unanimously[1] accept “PEP 810, Explicit lazy imports”. Congratulations! We appreciate the way you were able to build on and improve the previ...
discuss.python.org
November 3, 2025 at 4:36 PM
Reposted by Trey Hunner
I taught sets in Python TODAY and completely forgot about this joke. 😭

I even talked about |, &, ^, and - in relation to Venn diagrams!

🤦
November 1, 2025 at 4:34 AM
Now that Python 3.9 is officially end-of-life'd, it's time for open source maintainers to check out all the cool new features in Python 3.10! 😅
October 31, 2025 at 10:16 PM
Reposted by Trey Hunner
Python 3.9 is officially EOL!

Congratulations to @lukasz.langa.pl on a wonderful run as release manager! 🖤

discuss.python.org/t/the-final-...
The final Python 3.9 security fix release is out!
Python 3.9.25 is available now! If you’re still using that, grab the sources and build the update as there’s some final fixes: Security (low severity) gh-136063: email.message: ensured linear comp...
discuss.python.org
October 31, 2025 at 8:05 PM
Writing a t-string is pretty much as simple as writing an f-string. You just use a t instead of an f. But using the Template object that you get back from a t-string isn't nearly as simple as using a string. Read more ‘‰ https://trey.io/n4mlgb #Python
October 31, 2025 at 6:05 AM
"And the equality operator doesn't work very well with iterators." Read the full article: Checking whether iterables are equal in Python ¸ https://trey.io/0frqkp #Python
October 30, 2025 at 6:05 AM
You can also format datetime objects with f-strings in Python because datetime objects support the same C-style format codes within f-string format specifiers Read more ‘‰ https://trey.io/l4b84k #Python
October 30, 2025 at 12:26 AM
Starting now ⏰
My final #Python office hour of 2025 will be in 2 hours (10am PDT / 5pm UTC).

Come say hi, ask a question, or just hang out and see what's discussed.

See you there! 😊
Python Morsels Office Hours
Join Trey for 13 weekly office hour sessions. Free for everyone!
pym.dev
October 29, 2025 at 4:59 PM
My final #Python office hour of 2025 will be in 2 hours (10am PDT / 5pm UTC).

Come say hi, ask a question, or just hang out and see what's discussed.

See you there! 😊
Python Morsels Office Hours
Join Trey for 13 weekly office hour sessions. Free for everyone!
pym.dev
October 29, 2025 at 3:00 PM
"This allows Python developers to make tools that can accept t-strings and can pre-process the interpolation parts before combining all the parts together." https://trey.io/n4mlgb

#Python
October 29, 2025 at 12:26 AM