Rodrigo Girão Serrão 🐍🚀
banner
mathspp.com
Rodrigo Girão Serrão 🐍🚀
@mathspp.com
I'll help you take your Python skills to the next level!

Get a daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops

Pydon'ts – free Python book 👉 https://mathspp.com/books/pydonts
Quick!

How many string methods that change the case of a string can you name?

I'll give you a hint:

I thought there were only 5 but I was wrong.
November 10, 2025 at 2:42 PM
All Python objects have a Truthy/Falsy value.

This is the value of an object when used in a Boolean context.

For example, when used in the condition of an `if` statement.

Most objects are Truthy, with a few exceptions.

For most types, the “nothing” or “empty” value is Falsy.
November 10, 2025 at 10:54 AM
It just hit me that programming is like chess.

Everyone can play.

But not everyone plays beautifully…

It requires practice and calculated moves.

Moves that look like arbitrary choices…

But if you know, you’ll see how each decision builds towards a readable codebase.
November 9, 2025 at 5:48 PM
Just published a new article about the new Python 3.14 module `compression`.

This module offers a neat way to access the 5 compression modules we have in Python:

👉 bz2
👉 gzip
👉 lzma
👉 zlib
👉 zstd

The first four were already available as standalone modules...
November 8, 2025 at 12:02 AM
When building complex readable strings, consider building them out of smaller fragments.

The function `oxford_comma`, shown below, demonstrates this technique.

What's the point of the smaller fragments?
November 7, 2025 at 2:25 PM
Python has a very well-known naming convention:

Names that start with a leading underscore are “private”.

This means the outside world has no business using them.

E.g., attributes and methods starting with `_` in a class mean they're for that class only.
November 6, 2025 at 12:03 PM
I'm really enjoying this idea I stole from Simon Willison

I now have a `tools` subdomain where I host small HTML+JS tools built with LLMs that help me with whatever random things I need.

E.g., I have one that pre-fills my testimonial form and generates a URL I can share easily!
November 5, 2025 at 6:58 PM
The methods `strftime` and `strptime` can be used to convert dates/times into strings and vice-versa.

Here's a mnemonic to help you:

👉 `strptime` has a “P” for “Parse date/time”, so string -> date
👉 `strftime` has an “F” for “Format date/time”, so date -> string
November 5, 2025 at 12:01 PM
A generator, duck typing, and a branchless conditional walk into a bar...

You can read the rest of this Python joke here 👉 mathspp.com/blog/a-gene...
A generator, duck typing, and a branchless conditional walk into a bar
A generator, duck typing, and a branchless conditional walk into a bar.
mathspp.com
November 4, 2025 at 9:28 PM
The string method `str.split` has a parameter `maxsplit` that determines the maximum number of splits that will be performed.

The returned list with the splits (and possibly the remainder of the string) has a maximum length of `maxsplit + 1`.
November 4, 2025 at 11:58 AM
Yesterday's training culminated with creating a couple of projects (with uv).

We then uploaded them to (Test) PyPI and we got people to install each other's apps and run them on their own computers.

It was clearly a moment of *fun* for folks involved. 🤩
October 31, 2025 at 1:56 PM
This is your friendly reminder that str.split accepts a parameter to determine the maximum number of splits. You get up to n splits and the remainder of the string.
October 31, 2025 at 1:51 PM
Days 2 and 3 were a success, if I might say so myself.

The grounded, fundamental approach to OOP resonated well with the participants.

Even those who already knew OOP said they learned a lot by starting with the fundamentals!

What a surprise! (Not...)
October 29, 2025 at 11:42 PM
Live-coding during trainings + automatically syncing to git so everyone has access to what I'm typing =

Very informative git history.
October 28, 2025 at 1:00 PM
Yesterday went well.

Today I'm teaching OOP from the ground up.

But like, REALLY from the ground up.

Not just “you write class Something then __init__ and `self` is the first argument because reasons”.

Might turn this into a chapter for my book “Pydon'ts”, actually...
There's nothing quite like the excitement of being about to start a week-long Python training.

Being this excited about my job feels illegal 🤣
October 28, 2025 at 9:40 AM
Python is for everyone ❤️.

Become a PSF member if you can!
TLDR; The PSF has made the decision to put our community and our shared diversity, equity, and inclusion values ahead of seeking $1.5M in new revenue. Please read and share. pyfound.blogspot.com/2025/10/NSF-...
🧵
The official home of the Python Programming Language
www.python.org
October 27, 2025 at 5:01 PM
There's nothing quite like the excitement of being about to start a week-long Python training.

Being this excited about my job feels illegal 🤣
October 27, 2025 at 12:44 PM
Believe it or not, it took me 30+ min and nagging a core dev to get this TINY documentation issue fixed.

But at least I'll sleep well tonight, knowing all “See also” call outs are correctly formatted.
October 26, 2025 at 2:40 PM
strptime vs strftime

strPtime has the P for “parse time”

So it'll accept a string and Parse a time from it.

strFtime has the F for “from time” or “format time”

So it'll accept a time/date/datetime and Format it as a string.

You're welcome 🤗
October 26, 2025 at 12:12 PM
Yesterday I was reading the “What's new in Python 3.14” doc page.

Not just the headlines; I was reading the whole document.

(Looking for ideas for Python tips to share in my newsletter.)

And damn... The community and the core devs are on fire!
October 21, 2025 at 10:43 AM
I'd just like to reiterate the honour it is to receive this award and I'm deeply humbled by the fact that all the other recipients (Katie, Sarah, and past recipients) have made such meaningful contributions to the community and yet I'm among them!

This is just the start :D
October 16, 2025 at 11:58 AM
There's just SO MUCH STUFF in Python 3.14. ✨

I decided I'm going to share the new updates, drop by drop, in my Python drops 🐍💧 newsletter.

If you want to learn about what's new in Python 3.14 without getting overwhelmed, subscribe 👉 mathspp.com/drops
Python drops 🐍💧 newsletter
Take your Python 🐍 skills to the next level. 🚀
mathspp.com
October 13, 2025 at 5:20 PM
Maybe it's too early, but I'm having a hard time understanding the difference between `pathlib.Path.move` (new in Python 3.14) and `pathlib.Path.rename`.

Maybe the edge cases are different, but isn't the “main behaviour” the same?
October 13, 2025 at 7:12 AM
I've turned this blog post cheatsheet into a downloadable cheatsheet.

You can get the cheatsheet from here: mathspp.com/blog/uv-chea...
October 10, 2025 at 8:34 AM
This was in my drafts for almost a year.

It's published now.

mathspp.com/blog/pydonts...
Functions: a complete reference | Pydon't 🐍
This article serves as a complete reference for all the non-trivial things you should know about Python functions.
mathspp.com
October 6, 2025 at 2:11 PM