In the dynamic typing you are perpetuating the type problem when you add the int argument check. If you pass a string instead of an int you then break the declared return type (return a str instead of an int). That would leave a nasty mess if I call this function without reading the source or running a type checker. At minimum the return should be "int | str"
1) Zen of Python tells us "Readability counts." So about "slicing" section of your video it might be a good practice to use slice(). every_third = slice(None, None, 3) lst_of_nums[every_third] # Yes, one may argue that there's more hassle, but consider readability and reusability. 2) Magic line - if __name__ == "__main__": This part could have been presented better. As this magic line is used for orchestrating functions, presenting main interface and running tests. def main(): """ Orchestrates the execution of function1, function2, and function3. """ data = function1() result = function2(data) function3(result) ... if __name__ == "__main__": def test(): """ Runs tests to validate the functions. """ assert function1() == "Hello", "function1() should return 'Hello'" assert function2("Hello") == "Hello, world!", "function2() should return 'Hello, world!'" function3("Hello, world!") # This should print "Hello, world!" test() # Run tests first main() # Then run the main function
*args, **kwargs are like "self", you don't have to use these names. Just never use anything else because you'll make whoever reads your code very cross if you use something else. With *args only the astericks matter. That says, take all the positional arguments and put them in a tuple. **Kwargs plus all the keyword arguments and puts them in a dictionary. This means you don't have to know how many positional arguments there are or what the keyword arguments are. This is especially common when you're passing your arguments from a child class to a super class.
@@circuithijacker Async is usually for performance reasons. Python is 100x-10.000x slower than real programming languages. The GIL gives it the rest. Why would you try to optimize a python code? It's a scripting language for rapid prototyping or to glue packages together.
@vornamenachname906 I typically use it for event loops and controlling robots. Sometimes, I'll do robot control with ROS for that. I create stuff in Javascript, Java, C, C#, and sometimes C++. But, the performance argument is quite offset by using libraries or calling Ctypes, Cython, or CFFI. The rapid development time also really offsets any disadvantages I have ever come across in 45 years of programming. The real disadvantage to Python, as far as I'm concerned, is protecting any IP in the code. But much of what I do is open source. Python is a real language, but if you really want to program in a real language, program in assembly language (any) or onto the bare metal in binary with toggle switches, which I've done and it is an experience everyone should do at least once.
📬 Join my Newsletter: techwithtim.net/newsletter
Bro you left us hanging at the hardest part of the rust series
Yet another masterpiece from our boy Tim. Great work, make more videos like this
Excellent video!
welcome back SIR
Great ❤❤❤
In the dynamic typing you are perpetuating the type problem when you add the int argument check. If you pass a string instead of an int you then break the declared return type (return a str instead of an int).
That would leave a nasty mess if I call this function without reading the source or running a type checker.
At minimum the return should be "int | str"
Hi @tim may i ask you: how do you record your videos in this good quality? I want to start a channel aswell and i like your quality.
Do Tim have scikit learn tutorial?
When we are dealing with web systems, It is true, that python is not scalable at all?
Legend
1) Zen of Python tells us "Readability counts."
So about "slicing" section of your video it might be a good practice to use slice().
every_third = slice(None, None, 3)
lst_of_nums[every_third] # Yes, one may argue that there's more hassle, but consider readability and reusability.
2) Magic line - if __name__ == "__main__":
This part could have been presented better. As this magic line is used for orchestrating functions, presenting main interface and running tests.
def main():
"""
Orchestrates the execution of function1, function2, and function3.
"""
data = function1()
result = function2(data)
function3(result)
...
if __name__ == "__main__":
def test():
"""
Runs tests to validate the functions.
"""
assert function1() == "Hello", "function1() should return 'Hello'"
assert function2("Hello") == "Hello, world!", "function2() should return 'Hello, world!'"
function3("Hello, world!") # This should print "Hello, world!"
test() # Run tests first
main() # Then run the main function
I had a doubt. In the *args and **kwargs, should the names be same as it is or I just have to use the * one /twice depending on what im doing?
*args, **kwargs are like "self", you don't have to use these names. Just never use anything else because you'll make whoever reads your code very cross if you use something else.
With *args only the astericks matter. That says, take all the positional arguments and put them in a tuple. **Kwargs plus all the keyword arguments and puts them in a dictionary.
This means you don't have to know how many positional arguments there are or what the keyword arguments are. This is especially common when you're passing your arguments from a child class to a super class.
"with" in python 😇
"with" in js 💀
In for/while else portion of the video, why not just put the else statement within the for loop
That's an error, an else needs a preceding if, for or while in the same scope.
Make an async video
Bruhhh python and Async , whyyyy 😂
@vornamenachname906 why not?
I have a few in my channel already
@@circuithijacker Async is usually for performance reasons. Python is 100x-10.000x slower than real programming languages. The GIL gives it the rest. Why would you try to optimize a python code?
It's a scripting language for rapid prototyping or to glue packages together.
@vornamenachname906 I typically use it for event loops and controlling robots. Sometimes, I'll do robot control with ROS for that. I create stuff in Javascript, Java, C, C#, and sometimes C++. But, the performance argument is quite offset by using libraries or calling Ctypes, Cython, or CFFI.
The rapid development time also really offsets any disadvantages I have ever come across in 45 years of programming. The real disadvantage to Python, as far as I'm concerned, is protecting any IP in the code. But much of what I do is open source. Python is a real language, but if you really want to program in a real language, program in assembly language (any) or onto the bare metal in binary with toggle switches, which I've done and it is an experience everyone should do at least once.
Too easy brah make a multiprocessing crash course plz
For 2025?? C'mon Tim.. this has been explain a lot of times, nothing interesting to me. Why you don't talk about Pydantic AI for example?
Relax, show off. Let him explain this to beginners.
w