Python deep dive every Monday 🐍🚀 -> https://mathspp.com/insider
Short daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops
Today I got all of it!
First, my computer froze and I couldn't even share my screen.
Then, at some point my internet connection went POOF and I dropped off the call... 🤦
Hopefully now I'm good again for a dozen more talks.
Today I got all of it!
First, my computer froze and I couldn't even share my screen.
Then, at some point my internet connection went POOF and I dropped off the call... 🤦
Hopefully now I'm good again for a dozen more talks.
#Python #Berlin
discuss.python.org/t/pep-814-ad...
discuss.python.org/t/pep-814-ad...
How many are there, and what are they?
It's nice that the number is so small that you can actually probably remember all of them fairly easily.
How many are there, and what are they?
But I never know if it's
def clamp(v):
return min(max(v, low), high)
or
def clamp(v):
return min(max(v, high), low)
Always need to stop and think about it for a minute.
But I never know if it's
def clamp(v):
return min(max(v, low), high)
or
def clamp(v):
return min(max(v, high), low)
Always need to stop and think about it for a minute.
If you have a project and want to test it, your tests will import your project.
So, you need to install pytest as a dependency INSIDE your project.
If you install it globally, when you run it, it can't see your own project.
If you have a project and want to test it, your tests will import your project.
So, you need to install pytest as a dependency INSIDE your project.
If you install it globally, when you run it, it can't see your own project.
Don't use this if you have JSON in a file. Use `load` for that.
This is for when the data comes in a payload, for example.
Don't use this if you have JSON in a file. Use `load` for that.
This is for when the data comes in a payload, for example.
✅ An exit code of 0 means success; your program terminated without any issues.
❌ Any other integer exit code means “error”.
✅ An exit code of 0 means success; your program terminated without any issues.
❌ Any other integer exit code means “error”.
Check out the interview with @mathspp.com, Programme Team for EuroPython 2025 blog.europython.eu/humans-of-ep...
#europython #conference
Check out the interview with @mathspp.com, Programme Team for EuroPython 2025 blog.europython.eu/humans-of-ep...
#europython #conference
I didn't forget to start the recording.
That's a great start to the day :D
I didn't forget to start the recording.
That's a great start to the day :D
Isn't this elegant?
Isn't this elegant?
Runtime vs static type checking time.
Runtime vs static type checking time.
Take a look at the function `choice` shown below.
Note how it's being called as `choice(3, "hey!")`.
Will this type check or not?
If it does, what's the revealed type?
The right answer might surprise you!
It surprised me. 🤷
Take a look at the function `choice` shown below.
Note how it's being called as `choice(3, "hey!")`.
Will this type check or not?
If it does, what's the revealed type?
The right answer might surprise you!
It surprised me. 🤷
In Python, and in any other programming language 👇
In Python, and in any other programming language 👇
You can use `[...-...]` to represent character ranges and `*` to match arbitrary text.
But note that `glob` does NOT support regex syntax!
This is just similar.
You can use `[...-...]` to represent character ranges and `*` to match arbitrary text.
But note that `glob` does NOT support regex syntax!
This is just similar.
But they're very different.
Here's how to use NewType and TypeAlias in Python 👇
But they're very different.
Here's how to use NewType and TypeAlias in Python 👇
Just go to mathspp . com / drops 🤣
If you want to get smarter about Python in just 3 min/day, follow the QR code to sign-up.
Just go to mathspp . com / drops 🤣
If you want to get smarter about Python in just 3 min/day, follow the QR code to sign-up.
If you want to get smarter about Python in just 3 min/day, follow the QR code to sign-up.
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]}
```