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
This won't work if v is something like a generator, right?
November 15, 2025 at 4:57 PM
🙌
November 15, 2025 at 11:30 AM
I should take a look at that module to see what's there. I keep forgetting about it and while you're right that folks that really need it will likely already have numpy around it's good to know what's a single import away...
November 14, 2025 at 6:34 PM
Hehehe, that's only until those SEO farmers write sh177y articles and outrank me :)
November 14, 2025 at 6:32 PM
By the time the C++ is compiled, my Python script has finished running 🤪

Yeah, this is O(n^2) but the focus of this drop is to showcase the behaviour of deque and not suggest that this is the best possible implementation of a sliding window in Python.
November 14, 2025 at 6:31 PM
When I'm feeling fancy, I define some methods in a more “functional” way.

I just have fun writing code like this for myself 🤪

👇 yay or nay?
November 14, 2025 at 1:27 PM
We'll race in reverse. Last to submit, wins.
November 12, 2025 at 8:12 PM
I don't have 0 ideas. I have too many ideas given the 3 proposal limit. I just have to sit down and submit them :)
November 12, 2025 at 8:12 PM
And I'm still at 0 proposals submitted :P
November 12, 2025 at 3:57 PM
Oh this is fun :D
November 12, 2025 at 1:40 AM
Also, remember:

⛔️ NEVER use `assert` with security-related or sensitive checks!

Like, never.

That's a sure-fire way of running into problems because `assert`s can be “turned off”...

And you don't want someone stealing your bank details because an `assert` didn't run!
November 11, 2025 at 2:19 PM
In front of the expression, add a comma and then a custom string.

That custom string is the error message that will show up in front of the `AssertionError` if the assertion fails during runtime.

Make sure it's a good error message with helpful context!
November 11, 2025 at 2:19 PM
I was thinking about those 6, yeah: upper, lower, title, capitalize, casefold, swapcase
November 10, 2025 at 5:44 PM
Oh no! That's the type of bug I would take ages to find...
November 10, 2025 at 5:44 PM
For example, ALL functions are Truthy, regardless of what they do.

Even a function that does nothing is Truthy.

```py
def foo():
pass

print(bool(foo)) # True
```

(By the way, you can check the Truthy/Falsy value of something with the built-in `bool`.)
November 10, 2025 at 10:54 AM
Then, all other values are “Truthy”.

E.g., the empty list is Falsy but any other list is Truthy.

So, you can use the Truthy/Falsy value of a list to check if it's empty.

This is very idiomatic in Python.

Some other types don't have Falsy values!
November 10, 2025 at 10:54 AM