Trey Hunner π
@treyhunner@mastodon.social
#Python & #Django educator & team trainer
I help folks sharpen their Python skills with https://pythonmorsels.comππͺ
Also: ostrovegan, sentientist, YIMBY, and I think economics is highly underrated. I don't post about any of those topics very often.
he/him
- π My Weekly Newsletter
- https://pym.dev/newsletter
- π Python Exercises
- https://www.pythonmorsels.com
- πΊ YouTube
- https://www.youtube.com/@PythonMorsels
- πΈ Personal Blog
- https://treyhunner.com
Recent public posts
- Python Tip #289 (of 365): Add context to exceptions with add_note. def load_config(path): try: return json.loads(Path(path).read_text()) except json.JSONDecodeE...
- Python Tip #288 (of 365): Show a value's repr with "!r" in f-strings. >>> name = "Trey" >>> print(f"Name: {name}") Name: Trey >>> print(f"Name: {name!r}") Name:...
- Python 3.10 reached end of life a couple weeks ago. If you maintain a library and you're wondering what's in Python 3.11 that you can use, here's a cheat sheet....
- I just played a text adventure game all about Python 3.15's new features. uvx --python 3.15 whatsnewt. Score 299 of 375 Puzzles 14 of 18 Souvenirs 6 of 8 Rooms ...
- Python 3.15 is now out! ππ My favorite new features include: β’ UTF-8 default file encoding everywhere (less buggy cross-platform reads/writes!) β’ a new sampli...
- @AlSweigart 32GB. Had 16 a couple years ago and 8 a few years before that.
- Python Tip #281 (of 365): Bundle your package into one runnable file with zipapp. $ python3 -m zipapp src -m "greet.cli:main" -p "/usr/bin/env python3" -o greet...
- Python Tip #276 (of 365): Make self positional-only when accepting "**kwargs". This class accepts arbitrary keyword arguments... except for self: >>> class Name...
- Python Tip #275 (of 365): Pre-fill arguments with functools.partial. >>> from functools import partial >>> hex_to_int = partial(int, base=16) >>> hex_to_int("CA...
- Python Tip #257 (of 365): Consider "import datetime as dt". The fact that the datetime module and the datetime class are spelled the same way is VERY confusing....
- βIf you find subprocess.run to be a little too verbose, you might consider writing a custom wrapper function or two for your own use cases.β Read more π https:...
- βNote that passing generator expressions into iterable-accepting functions and classes makes something that looks a bit like a custom comprehension.β Read more ...
- Python Morsels now includes Daily Recall: a spaced repetition system for Python & Python-adjacent learning. It's basically Whereabouts.Earth but for Python. I'v...
- Python Tip #243 (of 365): Write automated tests. You can test manually (run your code to make sure it works), or write automated tests: code that tests your cod...
- βThe sorted function accepts an optional reverse argument.β Read more π https://pym.dev/sorting-in-python/ #Python
- Whereabouts Daily πΊοΈ August 31, 2026 5/5 countries in 7/13 guesses π‘π’π‘π’π’ https://whereabouts.earth/daily/ #Whereabouts
- βThe name deque stands for "double-ended queue", meaning deque objects are actually a sort of hybrid structure: they can be used as a stack, used as a queue, or...
- Python Tip #242 (of 365): Prefer isinstance over type for type checking. Do this: isinstance(value, int) Not this: type(value) == int. Unlike comparing with typ...
- Whereabouts Daily πΊοΈ August 30, 2026 5/5 countries in 7/13 guesses π‘π’π’π‘π’ https://whereabouts.earth/daily/ #Whereabouts
- βWhen you need to look up one value based on another in Python, you can use a dictionary as a mapping of key-value pairs.β Read more π https://pym.dev/using-di...