Type Hinting Makes Your Code More Professional

preview_player
Показать описание
In this video we learn why type hinting makes your Python code more professional and how to do it.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

🌐 Social Media & Contact 🌐

Timestamps
(0:00) Intro
(0:17) Type Hinting Basics
(6:17) Collection Types
(9:28) Custom Types
(13:26) Advanced Types
(19:42) Generics & Type Variables
(24:03) Outro
Рекомендации по теме
Комментарии
Автор

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.

alperengencoglu
Автор

I'm using type hinting, but that's totally different level. Great

Delirium
Автор

What about returns or inputs with numpy?

xrdgx
Автор

The intro is too loud in comparison to the rest of the video. This has been a problem for a long time now.

MangoNutella
Автор

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]

yoavmor
Автор

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

loki
Автор

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]:
----

josefhamelink
Автор

Have you ever considered learning Rust? Nice video btw!

aymancassim
welcome to shbcf.ru