Trey Hunner

treyhunner.com · Personal blog · on HN since 2014

Trey Hunner, a Python trainer, writes tutorials on Python idioms, built-ins, comprehensions and tooling, including uv scripts.

What HN saysHN commenters link his lazy self-installing uv script post for the shebang trick, and his animated list comprehension and PyCon posts.
31HN people shared it
10linked it in comments
38stories submitted
1.6Kstory points
9 months agolast shared
2014people per year2026

Most-shared posts

  1. 1
    Lazy self-installing Python scripts with uv
    4 people · 11 points · first shared 2024 · 1 comments on HN
  2. 2
    Python: Range is not an iterator (2018)
    4 people · 5 points · first shared 2018 · discussion on HN
  3. 3
  4. 4
    The problem with inheriting from list and dict in Python
    3 people · 3 points · first shared 2019 · discussion on HN
  5. 5
    Python built-ins worth learning
    2 people · 575 points · first shared 2019 · 118 comments on HN
  6. 6
    Asterisks in Python
    2 people · 222 points · first shared 2018 · 106 comments on HN
  7. 7
    Counting Things in Python: A History
    2 people · 213 points · first shared 2015 · 51 comments on HN
  8. 8
  9. 9
    The Idiomatic Way to Merge Dictionaries in Python
    2 people · 38 points · first shared 2016 · 9 comments on HN
  10. 10
    What's great about Python 3.10? – Trey Hunner
    2 people · 6 points · first shared 2021 · discussion on HN
  11. 11
    Why you should be using pathlib (Python)
    2 people · 4 points · first shared 2018 · discussion on HN
  12. 12
    Unique sentinel values and identity checks in Python
    2 people · 3 points · first shared 2019 · discussion on HN
  13. 13
    How to have a great first PyCon
    2 people · 2 points · first shared 2018 · discussion on HN
  14. 14
    Supporting Both Django 1.7 and South
    2 people · 1 points · first shared 2014 · discussion on HN
  15. 15
    Python List Comprehensions Explained Visually
    1 people · 138 points · first shared 2015 · 78 comments on HN

What HN people wrote when they linked it

celias · 2019-10-31
Here are a couple of articles about attending PyCon Trey Hunter's article "How to have a great first PyCon" including advice on how to overcome feeling like an imposter or an outsider https://treyhunner.com/2018/04/how-to-make-the-most-of-your-first-pyco… Al Sweigart's PyCon advice, including his shirt color trick for meeting new people https://automatetheboringstuff.com/how-to-do-pycon.html
tsurantino · 2015-12-02
For those confused - the visual part is done in a GIF (i.e. http://treyhunner.com/images/list-comprehension-condition.gif). I think animating the transformation from a normal loop to a list comprehension is a great way to show how the syntax translates between the two forms. Very awesome and comprehensive post.
trymas · 2025-10-30
You can setup uv inside your script, without a project. Example: https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-wit…
simonw · 2025-07-06
Use this as your shebang line: #!/usr/bin/env -S uv run --script https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-wit… I don't think requiring all CLI tools to be "native binaries" makes sense. Plenty of popular CLI tools are not compiled binaries. The Python and Node.js ecosystems run on those.
nikkindev · 2025-01-28
“Lazy self-installing Python scripts with uv”[1] article from Trey Hunner has more details with examples [1] https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-wit…
sdoering · 2020-07-27
Thank you very much. I am using python for some time now. Stumbled upon this, but never took the time to read up on it. If anybody also wants to know more I found this extensive post explaining the concepts behind * and in python (not in multiplication): https://treyhunner.com/2018/10/asterisks-in-python-what-they-are-and-h…
edudobay · 2017-05-04
Regarding Python, there _is_ a solution for the 3.x, <3.5 world. I would suggest the itertools.chain approach as noted in the "Chain items" section here: http://treyhunner.com/2016/02/how-to-merge-dictionaries-in-python/
peter_l_downs · 2014-04-01
Yeah, that would be awesome. I haven't looked into it yet but if you'd be willing to help out we'd be happy to accept contributions! The one thing that I think might be tricky with including standard migrations is keeping them compatible with Django 1.4-1.6; although it seems to be possible to have both in a given package [0] it doesn't seem all that user-friendly. [0]: http://treyhunner.com/2014/03/migrating-to-django-1-dot-7/
asicsp · 2021-11-25
I'm a self-published author and these are my offers till end of this month: 1) "Practice Python Projects" (https://learnbyexample.gumroad.com/l/py_projects/blackfriday) ebook is free (normal price $10) 2) "Learn by example Python bundle" (https://learnbyexample.gumroad.com/l/python-bundle/blackfriday) is $2 (normal price $12) - three ebooks titled "Python re(gex)?", "100 Page Python Intro" and "Practice Python Projects" 3) "All Books Bundle" (https://learnbyexample.gumroad.com/l/all-books/blackfriday) is $5 (normal price $22) - includes all three Python books mentioned in the bundle above and eight other books on regular expressions and CLI one-liners --- I know a couple of blog posts by indie creators with their own sales and links to other programming deals: * https://treyhunner.com/2021/11/python-black-friday-and-cyber-monday-sa… * https://www.blog.pythonlibrary.org/2021/11/24/python-black-friday-cybe…

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close