Get a daily drop of Python knowledge 🐍💧 -> https://mathspp.com/drops
Pydon'ts – free Python book 👉 https://mathspp.com/books/pydonts
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.
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.
I just have fun writing code like this for myself 🤪
👇 yay or nay?
I just have fun writing code like this for myself 🤪
👇 yay or nay?
⛔️ 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!
⛔️ 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!
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!
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!
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`.)
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`.)
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!
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!