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!

Python deep dive every Monday 🐍🚀 -> https://mathspp.com/insider

Short daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops
Convert data to a JSON string without writing to a file:

Just use `json.dumps`!

(The final S stands for String!)

```py
import json

data = {"k1": True, "k2": [73, 42, 10]}

s = json.dumps(data)
print(type(s), s)
# <class 'str'> {"k1": true, "k2": [73, 42, 10]}
```
January 20, 2026 at 2:31 PM
Let me teach you to break a Python law.

Iterators can only be traversed once:

```py
squares = (x ** 2 for x in range(3))

for sq in squares:
print(sq, end=", ")
# 0, 1, 4,

for sq in squares:
print(sq, end=", ")
# <no output>
```

The second loop produces no output!
January 19, 2026 at 3:26 PM
`itertools.pairwise` takes an iterable and produces overlapping pairs of consecutive elements:

```py
from itertools import pairwise

queue = ["John", "Joe", "Ana"]

for f, b in pairwise(queue):
print(f"{f}'s ahead of {b}.")
# John's ahead of Joe.
# Joe's ahead of Ana.
```
January 18, 2026 at 12:27 PM
This uv cheatsheet lists 40+ of the most and useful uv commands.

It groups the commands into 9 sections that correspond to major features/capabilities that uv has.

The cheatsheet is free to download and comes in light mode, dark mode, and high-contrast mode.

mathspp.gumroad.com/l/cheatsheet...
January 17, 2026 at 2:57 PM
A regex match has the method `groups`.

This method returns a tuple with all of the groups that the pattern contained.

Here's an example 👇
January 16, 2026 at 1:16 PM
If your code type checks and you don't have `Any` or `# type: ignore` then you won't get type errors at runtime.

Right?

Wrong...

```py
x: object = []
hash(x)
```

This code type checks but raises a `TypeError` at runtime...

What's going on here?
January 15, 2026 at 11:03 PM
Use CTRL + - to jump back to where your cursor was in VS Code.

Useful, for example, after clicking through a definition!
January 14, 2026 at 4:04 PM
This is the correct way to annotate Python methods that return self. 👇
January 14, 2026 at 1:44 PM
This technique will make sure your data is ALWAYS valid. 👇
January 13, 2026 at 1:33 PM
There's a fundamental rule of Python...

That `itertools.tee` breaks!

In a couple of hours, I'm sending a deep dive to 11,000+ email subscribers to help them understand how `tee` is able to do what it does!

Check the link in my profile to subscribe and to get the deep dive too!
January 12, 2026 at 3:27 PM
You can use the module `json` to read and write data in the JSON format, which is very suitable to represent the most common Python built-in types:

- lists
- dictionaries
- strings
- integers
- floats
- Booleans.
January 12, 2026 at 3:09 PM
With the new year comes a new cycle of conferences!

What do you want to know about attending/organising/speaking at Python conferences?

Drop your Qs below and I’ll address them the best I can 👇
January 8, 2026 at 10:48 AM
If you're in Lisbon, join us for the Python Lisbon Meetup.

It's this Thursday, 8th of January, at 7pm at Instituto Superior Técnico.

Find us on www.meetup.com/python-lisb... or on Discord discord.gg/DCNEYDKw9s for the full details!

We'll have 1 talk + ?? lightning talks + chat
Join the Python 🐍 Lisbon Meetup Discord Server!
Discord server for the Python Lisbon Meetup community. | 61 members
discord.com
January 5, 2026 at 2:03 PM
This is going to be a fun one, I can promise you that!
January 4, 2026 at 9:33 PM
I had an AMAZING idea for what would easily be my best blog article, ever.

But I might be a bit out of touch 😅

Help me figure this out:

Have you ever heard of the “P vs NP” problem?

Ok, and if you have, what about “NP-completeness”?

Have you heard of this term? Could you explain it back to me?
December 20, 2025 at 12:54 PM
Do you folks know any meetups that would be happy to host a remote talk?

I have a couple of new talk ideas that I'd love to get some feedback on!
December 19, 2025 at 7:02 PM
Reposted by Rodrigo Girão Serrão 🐍🚀
If you only remember to do one thing today, it should be proposing a talk for #PyConUS 2026. CFP closes today!

us.pycon.org/2026/speakin...
Proposal Guidelines
PyCon US 2026
us.pycon.org
December 19, 2025 at 5:44 PM
What if... I started streaming regularly (weekly?) on a quest to CONQUER Leetcode?

Start from #0001, and solve all Leetcode problems?

Is that something watchable or am I just being ridiculous?
December 15, 2025 at 3:02 PM
Advent of Code is over (only 12 days this year) and I'm kind of sad I don't have a reason to stream today.

I liked streaming!

What if I wanted to stream more?

What should I stream about?
December 13, 2025 at 4:03 PM
Reposted by Rodrigo Girão Serrão 🐍🚀
December 13, 2025 at 2:13 PM
It's so ANNOYING to break out of nested loops.

Auxiliary variables, conditional statements, non-linear paths through your code...

It's a mess!

But if you extract the looping logic to a generator, you get:

- less indentation ✨
- a flat loop you can easily break out of ✨
December 11, 2025 at 1:51 PM
📢 Public service announcement:

Don't buy from me:

Don't buy my books.

Don't sign-up for my courses.

Don't attend my cohorts.

Apparently, I'm a scammer. 🤷

At least, that's my interpretation of this comment from a subscriber...

Should I delete them from my mailing list?
December 10, 2025 at 1:33 PM
After yesterday's flop, today I'm live streaming to solve day 10 of Advent of Code and hopefully go back to day 9 part 2 to make progress on finishing it!
December 10, 2025 at 1:23 PM
A visualisation of day 7 from Advent of Code.

Worked on this during yesterday's stream, although the colouring was added off stream.
December 8, 2025 at 4:22 PM
7 days of Advent of Code diagrams from my streams and analysis sessions!
December 7, 2025 at 7:06 PM