Rodrigo Girão Serrão 🐍🚀

@mathspp.com

I'll help you take your Python skills to the next level! Python deep dive every Monday 🐍🚀 -> https://mathspp.com/insider Short daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops

How do you collapse runs of adjacent spaces in Python? That is, shorter runs of 2+ consecutive spaces so there's only 1 space there? I can't come up with a simple/straightforward way to do it with `str.join` and I'm surprised... What am I missing?

Hey all! It's almost time for the next Python Lisbon Meetup! 🐍 On Thursday, pyctrl will be talking about exceptions. We'll cover the origin of exceptions, their usage in OOP, how best to manage them, and more. It's going to be exceptional! 💎

What do LLMs see? I wrote a lil' tool that extracts the attention matrices out of open models and creates this typing visual, with each token's opacity changing according to its average attention score as the prompt progresses. Dimmer words are considered less important to the model.

FINALLY had technical issues while delivering a remote talk. Today I got all of it! First, my computer froze and I couldn't even share my screen. Then, at some point my internet connection went POOF and I dropped off the call... 🤦 Hopefully now I'm good again for a dozen more talks.

Introducing the PSF Community Partner Program! The PSF is very excited to announce this new in-kind offering that expands how we support Python community events and initiatives around the world, now and alongside future community support programs 💝🐍

Introducing the PSF Community Partner Program

The Python Software Foundation (PSF) is excited to announce the introduction of the PSF Community Partner Program. This new program is designed as an “in-kind” way for us to support Python events and initiatives with non-financial assistance through the use of the PSF logo and name, as well as promotional support via sharing qualified posts on PSF official social media accounts. The PSF looks forward to supporting Python community events and initiatives through this new program!The introduction of the PSF Community Partner Program grew out of our desire to find alternative ways to support the community during the pause of our Grants Program (read more about the resulting process below). Even so, we intend to continue offering this in-kind support program after the Grants Program reopens. Our big picture hope is that, over the long term, some community events and initiatives will continue to partner with the PSF while being financially dependent on sponsors and individual donors alone. The PSF is also working on the future of our Grants Program, including when and how we can reopen it in a way that ensures the program’s long-term sustainability while balancing the needs of the Python community. In light of the truly staggering outpouring of support from our community during the 2025 year-end fundraiser, we are now in a stronger position to reopen the Grants Program and are eager to give back in a thoughtful and sustainable way. More updates to come!As with the rollout of any new program, we anticipate small adjustments will need to be made for processes to flow smoothly and to ensure the program serves the Python community well. The PSF welcomes your comments, feedback, and suggestions regarding the new Community Partner Program on the corresponding Discuss thread. We also invite you to join our upcoming PSF Board or Grants Program Office Hour sessions to talk with the PSF Board and Staff synchronously. If you wish to send your feedback privately, please email grants@python.org. 

pyfound.blogspot.com

I've written this Python function so many times I should no longer be confused by it... But I never know if it's def clamp(v): return min(max(v, low), high) or def clamp(v): return min(max(v, high), low) Always need to stop and think about it for a minute.

One of my students today made this mistake. If you have a project and want to test it, your tests will import your project. So, you need to install pytest as a dependency INSIDE your project. If you install it globally, when you run it, it can't see your own project.

Diagram showing how using uv to install pytest globally will isolate it from everything else, as it should. But if you're testing a package, you want to have pytest as a dependency of that package since it'll be able to find your own package code.