Rodrigo GirΓ£o SerrΓ£o πŸπŸš€'s Avatar

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

1,137
Followers
310
Following
1,267
Posts
21.11.2024
Joined
Posts Following

Latest posts by Rodrigo GirΓ£o SerrΓ£o πŸπŸš€ @mathspp.com

Oh nice, that's better!

03.03.2026 17:41 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

At least you managed to make it work! For a while, I couldn't do anything at all :P

02.03.2026 15:24 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Not sure I follow what you mean by β€œon normally spaced strings less replacing to do”.

I like " {2,}" because it's easy to miss the double space in the original " +"... I'll replace it, thanks!

02.03.2026 15:23 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

I wrote 0 blog posts in February.

Today I already wrote 2.

Go figure. 🀷

02.03.2026 15:22 πŸ‘ 2 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Came up with 4 random ways to do this.

2, I recommend you use them (although 1 doesn't work!)

The other 2 are really cool β€” they use fixed points and `itertools.groupby` β€” but they'll be overkill 99.9% of times.

02.03.2026 14:40 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

I meant β€œThis is, shortEN runs of 2+ [...]”

02.03.2026 14:39 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Preview
Remove extra spaces Learn how to remove extra spaces from a string using regex, string splitting, a fixed point, and itertools.groupby.

It was a random thought, indeed.

For a bit more context, see the second approach and how it doesn't work 100%: mathspp.com/blog/remove-...

02.03.2026 14:38 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Nope because if you have newlines, for example, those will disappear!

02.03.2026 14:38 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

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?

02.03.2026 13:24 πŸ‘ 1 πŸ” 0 πŸ’¬ 4 πŸ“Œ 1

Ok, obrigado!

01.03.2026 15:31 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Pretty impressive! Annoying, but impressive!
And do you have any idea of how much data you spent? In case something similar happens to me πŸ˜‚
(My internet has been acting out.)

28.02.2026 10:03 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Pode dar um exemplo de cada sΓ³ para eu nΓ£o ter de rever a sΓ©rie atΓ© perceber? πŸ™

28.02.2026 07:27 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

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! πŸ’Ž

27.02.2026 12:46 πŸ‘ 2 πŸ” 2 πŸ’¬ 1 πŸ“Œ 0

How did it go? 😬

28.02.2026 07:22 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Thanks for sharing! Neither star nor asterisk are usages that shock me. And yeah, sometimes it’s implied by the context, absolutely.

24.02.2026 13:55 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Ahhhh that’s what you meant by McGugan boxes! Right :D thanks for the link

24.02.2026 13:54 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

That’s not what I meant with the question. _What_ are the McGugan boxes?

23.02.2026 22:03 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Then what do you do after I type

β€œdef f(args)”?

23.02.2026 16:27 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

🀣

23.02.2026 15:22 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Interesting... πŸ€”

23.02.2026 14:46 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

So if you're dictating the signature of the function

def f(*args):
...

You just say β€œdef F args”?

23.02.2026 14:46 πŸ‘ 0 πŸ” 0 πŸ’¬ 2 πŸ“Œ 0

I read it as β€œstar args”.

23.02.2026 13:25 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

How do you read `*args` in a function signature?

PLEASE reply with how you'd read it, I'm trying to prove someone wrong 🀣

Reposts are appreciated :D

23.02.2026 13:25 πŸ‘ 0 πŸ” 1 πŸ’¬ 4 πŸ“Œ 0

What’s the box drawing technique you’re referring to?

22.02.2026 22:49 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

πŸ‘€

22.02.2026 00:31 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Video thumbnail

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.

19.02.2026 12:14 πŸ‘ 256 πŸ” 42 πŸ’¬ 17 πŸ“Œ 8
Diagram showing how `itertools.compress` works, taking an iterable with data and an iterable with selectors and making a selection based on the Truthy/Falsy value of the selectors.

Diagram showing how `itertools.compress` works, taking an iterable with data and an iterable with selectors and making a selection based on the Truthy/Falsy value of the selectors.

`itertools.compress` explained in a simple diagram.

Useful when you need to filter an iterable of data based on a second iterable of flags or selectors.

19.02.2026 11:56 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Diagram explaining how starmap works across a stream of data for a given iterable with pairs (a, b) and a binary function f, producing the iterable with items f(a0, b0), f(a1, b1), etc.

Diagram explaining how starmap works across a stream of data for a given iterable with pairs (a, b) and a binary function f, producing the iterable with items f(a0, b0), f(a1, b1), etc.

How does this slide look?

18.02.2026 14:07 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Oh, must’ve missed the mastodon Q.

17.02.2026 22:35 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

Heh, I had a talk accepted... By accident, since I had withdrawn all my proposals already but I must've done it in between them accepting one of my talks and sending out the emails 🀣

16.02.2026 13:14 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0