Nice video. Also, one of the best advantages of type hinting is that you can benefit from IntelliSense / code suggestions in the function body for a variable which is passed to the function as parameter.
Since 3.10 you can also do ---- def myfunction(myparam: int | float) -> int | float: ---- instead of ---- from typing import Union def myfunction(myparam: Union[int, float]) -> Union[int, float]: ----
Extra thing I've learnt recently - you use the following to not do imports just for typing. Also types surrounded by semicolons is a legit syntax and can be used for types which won't be imported during execution. if typing.TYPE_CHECKING: from my_module import MyClass def myfunc(arg1: "MyClass"): pass
Nice video.
Also, one of the best advantages of type hinting is that you can benefit from IntelliSense / code suggestions in the function body for a variable which is passed to the function as parameter.
I'm using type hinting, but that's totally different level. Great
Thanks you always have something that I needed.
Since 3.10 you can also do
----
def myfunction(myparam: int | float) -> int | float:
----
instead of
----
from typing import Union
def myfunction(myparam: Union[int, float]) -> Union[int, float]:
----
Yes, best thing is to make mypy kind of module inbuilt in standard lib
Optional isn't a fancy way to mark optional function parameters.
It means the value can be None. Optional[T] is simply Union[T, None]
What about returns or inputs with numpy?
Thank you very nice 👍🏼
Extra thing I've learnt recently - you use the following to not do imports just for typing.
Also types surrounded by semicolons is a legit syntax and can be used for types which won't be imported during execution.
if typing.TYPE_CHECKING:
from my_module import MyClass
def myfunc(arg1: "MyClass"):
pass
Have you ever considered learning Rust? Nice video btw!
He has rust tutorials
@@notnalin Really where?
@@aymancassim8944 ruclips.net/p/PLzMcBGfZo4-nyLTlSRBvo0zjSnCnqjHYQ
Thx.
The intro is too loud in comparison to the rest of the video. This has been a problem for a long time now.
i think it's fine, i mean most people skip it anyways :P
My brain are brokenn ;-;