Trey Hunner
@trey.io
Python & Django team trainer
I help folks sharpen their Python skills with https://PythonMorsels.com 🐍🍪
YIMBY. 95% vegan.
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
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.
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
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
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.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
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.com/treyhunner/p...
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?”
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
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?”
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! 🐝
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...
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
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...
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...
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
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
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
Whenever I see nested loops in a comprehension, I think "flattening".
Read more ‘‰ https://trey.io/aeo9fg
#Python
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.
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
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.
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.
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
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
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__ 👇
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
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__ 👇
Some classes use a more memory efficient mechanism for attribute storage.
More in my new screecast on __slots__ 👇
(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.
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
(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.
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.
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: 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 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: 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]
Python 3.15 will include lazy imports, but it won't allow this:
lazy from module import *
lazy from module import *
November 3, 2025 at 8:37 PM
Python 3.15 will include lazy imports, but it won't allow this:
lazy from module import *
lazy from module import *
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
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
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...
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
Wooo, unanimous acceptance of 810!
Python is getting lazy imports!
So excited about this!
discuss.python.org/t/pep-810-ex...
Python is getting lazy imports!
So excited about this!
discuss.python.org/t/pep-810-ex...
Reposted by Trey Hunner
The Steering Council has accepted PEP 810 (explicit lazy imports) for Python 3.15!
discuss.python.org/t/pep-810-ex...
#Python #PEP810 #LazyImports #lazy #Python315
discuss.python.org/t/pep-810-ex...
#Python #PEP810 #LazyImports #lazy #Python315
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:29 PM
The Steering Council has accepted PEP 810 (explicit lazy imports) for Python 3.15!
discuss.python.org/t/pep-810-ex...
#Python #PEP810 #LazyImports #lazy #Python315
discuss.python.org/t/pep-810-ex...
#Python #PEP810 #LazyImports #lazy #Python315
I taught sets in Python TODAY and completely forgot about this joke. 😭
I even talked about |, &, ^, and - in relation to Venn diagrams!
🤦
I even talked about |, &, ^, and - in relation to Venn diagrams!
🤦
November 1, 2025 at 4:34 AM
I taught sets in Python TODAY and completely forgot about this joke. 😭
I even talked about |, &, ^, and - in relation to Venn diagrams!
🤦
I even talked about |, &, ^, and - in relation to Venn diagrams!
🤦
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
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! 😅
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-...
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
Python 3.9 is officially EOL!
Congratulations to @lukasz.langa.pl on a wonderful run as release manager! 🖤
discuss.python.org/t/the-final-...
Congratulations to @lukasz.langa.pl on a wonderful run as release manager! 🖤
discuss.python.org/t/the-final-...
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
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
"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
"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
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
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
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! 😊
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
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! 😊
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
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! 😊
Come say hi, ask a question, or just hang out and see what's discussed.
See you there! 😊
"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
#Python
October 29, 2025 at 12:26 AM
"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
#Python