Python deep dive every Monday 🐍🚀 -> https://mathspp.com/insider
Short daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops
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]}
```
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]}
```
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!
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!
```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.
```
```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.
```
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...
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...
This method returns a tuple with all of the groups that the pattern contained.
Here's an example 👇
This method returns a tuple with all of the groups that the pattern contained.
Here's an example 👇
Right?
Wrong...
```py
x: object = []
hash(x)
```
This code type checks but raises a `TypeError` at runtime...
What's going on here?
Right?
Wrong...
```py
x: object = []
hash(x)
```
This code type checks but raises a `TypeError` at runtime...
What's going on here?
Useful, for example, after clicking through a definition!
Useful, for example, after clicking through a definition!
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!
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!
- lists
- dictionaries
- strings
- integers
- floats
- Booleans.
- lists
- dictionaries
- strings
- integers
- floats
- Booleans.
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 👇
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 👇
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
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
#Python #Berlin
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?
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?
I have a couple of new talk ideas that I'd love to get some feedback on!
I have a couple of new talk ideas that I'd love to get some feedback on!
us.pycon.org/2026/speakin...
us.pycon.org/2026/speakin...
Start from #0001, and solve all Leetcode problems?
Is that something watchable or am I just being ridiculous?
Start from #0001, and solve all Leetcode problems?
Is that something watchable or am I just being ridiculous?
I liked streaming!
What if I wanted to stream more?
What should I stream about?
I liked streaming!
What if I wanted to stream more?
What should I stream about?
🗳️ @pumpichank.bsky.social
🗳️ @corona10.bsky.social
🗳️ @pablogsal.com
🗳️ @savannah.dev
🗳️ @yhg1s.bsky.social
discuss.python.org/t/steering-c...
Welcome Savannah & thank you to @gpshead.bsky.social for your service!
hugovk.github.io/python-steer...
🗳️ @pumpichank.bsky.social
🗳️ @corona10.bsky.social
🗳️ @pablogsal.com
🗳️ @savannah.dev
🗳️ @yhg1s.bsky.social
discuss.python.org/t/steering-c...
Welcome Savannah & thank you to @gpshead.bsky.social for your service!
hugovk.github.io/python-steer...
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 ✨
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 ✨
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?
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?
Worked on this during yesterday's stream, although the colouring was added off stream.
Worked on this during yesterday's stream, although the colouring was added off stream.