Today you are going to read about some weirdo. Who would like to use classes if we can use functions instead? Let's make a simple function with a cache by storing the cache inside the function. Don't ask questions why.
Did you know that's possible?
Today you are going to read about some weirdo. Who would like to use classes if we can use functions instead? Let's make a simple function with a cache by storing the cache inside the function. Don't ask questions why.
Did you know that's possible?
Let's talk about Protocol today. It allows you to have "duck typing". If an object has the required fields/methods, then the type checker keeps silent and no inheritance is required. It's a powerful thing to build interfaces.
Take a look.
Let's talk about Protocol today. It allows you to have "duck typing". If an object has the required fields/methods, then the type checker keeps silent and no inheritance is required. It's a powerful thing to build interfaces.
Take a look.
Did you know loops have an else option? It's unusual, and I recommend not using it, but it's good to know it exists.
Did you know loops have an else option? It's unusual, and I recommend not using it, but it's good to know it exists.
➕ I'm having fun
➖ I miss this guy
➕ I'm having fun
➖ I miss this guy
Did you know that Python has a function to check if an object is callable? This is particularly useful when building tricky tools.
Did you know that Python has a function to check if an object is callable? This is particularly useful when building tricky tools.
See the code screenshot? It triggers an exception because the variable is local due to its assignment at the end. So, you can't access it before assigning a value. Tricky, right?
Now you know. Stay sharp!
See the code screenshot? It triggers an exception because the variable is local due to its assignment at the end. So, you can't access it before assigning a value. Tricky, right?
Now you know. Stay sharp!
Using list() or [:] on a list makes a shallow copy, duplicating the container but keeping the same elements.
For tuples, tuple() or [:] retains the original since tuples are immutable. Python optimizes by having one immutable object with multiple references.
Using list() or [:] on a list makes a shallow copy, duplicating the container but keeping the same elements.
For tuples, tuple() or [:] retains the original since tuples are immutable. Python optimizes by having one immutable object with multiple references.
Did you know this code would cause an error in Python 3, but in Python 2, it would print 4? That's because list comprehensions were merely syntactic sugar in Python 2.
This knowledge might be useless, but it's still interesting. Want to read more like this? Follow me.
Did you know this code would cause an error in Python 3, but in Python 2, it would print 4? That's because list comprehensions were merely syntactic sugar in Python 2.
This knowledge might be useless, but it's still interesting. Want to read more like this? Follow me.
Did you know `auto` can auto-generate enum values? But if you want string values, use `_generate_next_value_`. Be cautious with `auto`; implicit values might cause mistakes.
Did you know `auto` can auto-generate enum values? But if you want string values, use `_generate_next_value_`. Be cautious with `auto`; implicit values might cause mistakes.
The new release is out. Check the link below.
The new release is out. Check the link below.
Today I'm gonna show you a simple, but useful thing about dataclasses in Python.
What if you want to bypass a value without having it inside dataclass? There is a way!
Today I'm gonna show you a simple, but useful thing about dataclasses in Python.
What if you want to bypass a value without having it inside dataclass? There is a way!
- touching the grass
- touching the grass
What's your general watching-learning speed?
What's your general watching-learning speed?