Posts

This profile is from a federated server and may be incomplete. Browse more on the original instance.

treyhunner, to random
@treyhunner@mastodon.social avatar

Out of curiosity, I searched for the hashtag on Mastodon and Twitter and scrolled back 16 hours and started counting posts. 🤔

I counted:

87 posts on Twitter on the PyCon hashtag 🐦

134 posts on Mastodon on the PyCon hashtag 🐘

The PyCon conversations have finally moved (mostly) to Mastodon! 🙌

Not a HUGE difference, but enough that I felt like there was more activity and decided to confirm my suspicion. 💗

anze3db,
@anze3db@fosstodon.org avatar

@treyhunner This is awesome momentum for the Mastodon Python community and exactly why I started building @fedidevs almost a year ago!

If anyone wants to see all Mastodon posts in one place and be able to filter/sort through them, check out the page: https://fedidevs.com/pycon24/

treyhunner, to python
@treyhunner@mastodon.social avatar

Python 3.7 reached the end of its life today. 🎉

Here are some Python 3.8 features you can now embrace:

• cached_property
• self-documenting f-string expressions
• walrus operator
• positional-only args
• passing dictionaries to reversed()

A few other favorites of mine:

• math.‍prod (like sum, but for multiplication)
• clearing the REPL with globals().clear()... this would break things in Python 3.7!
• argparse's add_argument method has an "extend" action

brianokken,
@brianokken@fosstodon.org avatar

@treyhunner I’ve decided to only support 3.10+ from now on. match is too awesome to wait.

jgomezdans,
@jgomezdans@fediscience.org avatar

@treyhunner cached_property looks really useful! How comes I never came across it before!!??

treyhunner, to python
@treyhunner@mastodon.social avatar

My students often ask me whether they can see a list of every dunder method that has. I've been meaning to compile a categorized list for years.

I finally did it.

Here's every dunder method in Python... all 115 of them! 🤯

https://pym.dev/every-dunder-method/

veronica,
@veronica@mastodon.online avatar

@treyhunner There should be a dunder mifflin too, although I think we are limited to Monty Python references in Python.

chrisjrn,
@chrisjrn@social.coop avatar

@treyhunner Or you can watch @thejcannon present them all in Dr Seuss-style rhyming couplets at last year's : https://www.youtube.com/watch?v=CSpzTx-S8B0

treyhunner, (edited ) to python
@treyhunner@mastodon.social avatar

Python 3.13 beta 1 just landed.

My favorite new feature is the new REPL.

Honestly, this may be my favorite feature since f-strings.

My write up on the differences between old and new REPLs:
https://treyhunner.com/2024/05/my-favorite-python-3-dot-13-feature/

chrysn,
@chrysn@chaos.social avatar

@treyhunner @fohrloop That does look awesome. Any chance those changes will come to python3 -m asyncio as well, or for the latter to just become the default?

treyhunner,
@treyhunner@mastodon.social avatar

@chrysn @fohrloop I imagine someone motivated to make that change would need to do it.

I assume "-m asyncio" makes up a fairly small portion of all REPL usage. That doesn't mean it is unimportant to those who use it of course!

treyhunner, (edited ) to random
@treyhunner@mastodon.social avatar

I've just updated my ~/.config/pip/pip.conf & my dotfiles repo to disallow pip installing outside virtual environments! 🎉

TIL 2 things about 's pip:

  1. pip has a config file. If I ever knew this, I'd forgotten.

  2. pip has an option that stops it from working outside of a virtual environment!

This is great for me because I use pipx and NEVER do global pip installs.

Info: https://unix.stackexchange.com/questions/492041/is-there-a-way-to-disable-pip-outside-of-a-virtual-environment

Thanks to @hynek's excellent uv video for this semi-related TIL 💜 https://youtu.be/_FdjW47Au30?si=5iRmMuWMdewRubNt

jugmac00,
@jugmac00@fosstodon.org avatar

@treyhunner afair I did a sudo apt remove python3-pip, but it has been a while

henryiii,
@henryiii@fosstodon.org avatar

@jugmac00 @treyhunner @hynek Yeah, I don't have a global pip either (homebrew). I do have a global pip3, but I'd never accidentally (or intentionally) type that. :)

treyhunner, to random
@treyhunner@mastodon.social avatar

Guess which Norwegian, needleworking, library-indexing, BeeWare contributing folks are now on Mastodon in preparation for a future Python conference. 🇳🇴🧵📚🐝

@yngvem & @marieroald!

bmispelon,
@bmispelon@mastodon.social avatar

@treyhunner @yngvem @marieroald Norwegians who do Python? That's not a common sight!

I'm also a Norwegian (kind of, only resident) who does Python and who's always happy to meet other snake loving friends

yngvem,

@hugovk @treyhunner @marieroald @catherinedevlin
We added more stickers to the table near the sprint boards now 🐢🪡

treyhunner, to python
@treyhunner@mastodon.social avatar

I attended my first Python conference 10 years and 10 days ago.

I wrote a meandering and nostalgic blog post (complete with links to old group selfie tweets) about the last 10 years of being part of the wider community.

I'm really grateful I decided to attend PyCon 2014 and that I came back for PyCon 2015 and went to DjangoCon 2015 as well.

https://treyhunner.com/2024/04/10-years-of-python-conferences/

ehmatthes,
@ehmatthes@fosstodon.org avatar

@treyhunner "I left a few days into the PyCon US 2014 sprints and I remember feeling a bit like summer camp was ending."

My family lightheartedly calls it nerd camp, but this captures exactly what it feels like to leave PyCon most years.

treyhunner, to python
@treyhunner@mastodon.social avatar

The ruff linter can now replace all my favorite linting & auto-formatting tools.

For many months, I've used these commands:

• ruff check . # lint
• ruff check --fix . # auto-fix

Now I also use:

• ruff format . # A Black equivalent

Instead of flake8 or pylint, I either use the ruff defaults (similar to flake8) or I enable the "PL" rules for pylint.

The --fix argument will auto-fix many linting errors too (similar to autopep8, autoflake, isort, pyupgrade, etc.).

treyhunner,
@treyhunner@mastodon.social avatar

The ruff formatter is intended to be a full replacement for the Black auto-formatter.

The "ruff format" command is in beta, though the developers now consider it "production-ready". It's 99.9% Black-compatible.

https://astral.sh/blog/the-ruff-formatter

Why replace other linters with ruff?

Black, flake8, & pylint are sluggish on large codebases (painful when used as pre-commit hooks).

Those other tools are written in , but the ruff formatter is written in , which allows it to be incredibly fast! 🚀

treyhunner,
@treyhunner@mastodon.social avatar

By the way, if newsletters are your thing (I know email isn't for everyone), sign up for my weekly Python tips newsletter.

I email out a tip every week. 🐍💡

Many are more distilled/coherent version of my blog posts and Mastodon posts, but I also often share advice that I haven't shared publicly elsewhere.

https://pym.dev/newsletter 💌

treyhunner, to python
@treyhunner@mastodon.social avatar

Python Community News released videos for 13 of the 15 nominees running for @ThePSF board of directors right now.

If you haven't voted yet, check these videos to hear each nominee answer a few questions.

https://www.youtube.com/playlist?list=PL9MuO5r3rpXJ5k-NEI3Gc6S3CZU7mGwvP

Thanks @kjaymiller & @jonafato for putting these together.

#Python #PSF

jonafato,
@jonafato@mastodon.social avatar

@treyhunner @ThePSF @kjaymiller I can't claim any credit here (participating would have been a conflict of interest). Jay did a fantastic job on this project, and it was definitely valuable for me as a voter.

treyhunner, to random
@treyhunner@mastodon.social avatar

What tips do you have for folks thinking of trying out Mastodon during #PyConUS this year?

3 of my tips:

  1. Follow the #PyConUS hashtag (yes you can follow a hashtag just like following a profile!)
  2. If you post and realize you forgot the #PyConUS hashtag, don't delete your post. Just edit it!
  3. Consider following the #PyCon hashtag also. Many folks use it without realizing that #PyConUS is the official one.

What tips do you have?

bitprophet,
@bitprophet@social.coop avatar

@ivory Nice! Thanks for the update 👍🏻

mborus,
@mborus@mastodon.social avatar

@treyhunner

Tips:

  • If you see someone mentioning a technology (or something else) you want to check out later, set a bookmark (Inside your client) in addition to boosting it, because it's hard to find what you boosted a few weeks later.

  • You are other people's algorithm. Make sure to boost interesting posts, otherwise they will not get visibility beyond an audience following the hashtag.

  • For those on iOS, have a look at #IceCubes, you can set in into a Twitter-like single column mode.

treyhunner, to python
@treyhunner@mastodon.social avatar

I'm offering lifetime access to Python Morsels from now through Monday. 🐍

If you're a frequent user and you plan to use it for at least a few more years, I highly recommend this deal. 💖

More details at https://pym.dev/lifetime-access-sale

video/mp4

treyhunner, (edited ) to random
@treyhunner@mastodon.social avatar

I'm doing something I've never done: I'm offering lifetime access to Morsels. ♾️

You can get access to all screencasts, articles, and exercises I publish for the price of a 2 year subscription. 🐍

This sale ends on November 27, 2023 💸

https://pym.dev/lifetime-access-sale

treyhunner, to random
@treyhunner@mastodon.social avatar

I've told my students that even though comprehensions are faster than loops, much of a loop's slowness was due to append method lookup time.

I just discovered that my knowledge is outdated.

Since Python 3.11, this "append" optimization isn't any faster! https://pym.dev/p/2gzr3/

This is thanks to PEP 569, which made method call lookups and lots of other stuff a bit faster.

https://docs.python.org/3/whatsnew/3.11.html#pep-659-specializing-adaptive-interpreter

More context (someone else noticed this a few days before I did): https://discuss.python.org/t/append-mylist-append-optimization-now-harmful/36028

j2kun,
@j2kun@mathstodon.xyz avatar

@treyhunner I was stoked when they finally did this

treyhunner, to django
@treyhunner@mastodon.social avatar

A controversial topic:

class-based views (CBVs) or function-based views (FBVs)? 🤔

I started with function-based views, but after a few years of using Django I pretty much moved fully to class-based views. Both have pros & cons (and vocal advocates).

The Django docs introduce FBVs first and then discusses CBVs as well as Django's built-in "generic class-based views" (GCBVs).

Django-REST-Framework also makes heavy use of CBVs.

But class-based views CAN be confusing.

treyhunner,
@treyhunner@mastodon.social avatar

But what if I need to inherit some of the original method's behavior and I'm not sure exactly how the method worked?

My first instinct is often to look at the original source code, but that involves digging through multiple mixin classes. 😢

This Classy Class-Based Views site can help with this "mixin hell" issue: https://ccbv.co.uk

This site "flattens" each view by grouping the code by each method rather than by each parent class.

There's also a DRF-focused site: https://cdrf.co

matthiask,
@matthiask@hachyderm.io avatar

@carlton I wrote a thing, here: https://406.ch/writing/composition-over-inheritance-the-case-for-function-based-views/

I could spend many more hours on this but I think it's "good enough" 😅

treyhunner, to programming
@treyhunner@mastodon.social avatar

I always love chatting with Jay Miller. 💖

@kjaymiller interviewed me at during the first day of sprints.

We chatted about:

• interacting with folks without discussing
• playing (my version of)
• how great chatting with other teachers & learners is
• getting feedback and validation
• contributing during sprints

Jay also interviewed @AlSweigart @pythonbynight, @ericholscher, @sethmlarson, Aseda Addai-Deseh, and @freakboy3742. Check the playlist!

https://www.youtube.com/watch?v=HzuXmzhFJ6Y&list=PL9MuO5r3rpXK_dfGDIlKqjiKZ5_YqZgxj&index=3

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines