Type Hinting Makes Your Code More Professional

Type Hinting Makes Your Code More Professional

NeuralNine

2 года назад

11,210 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Rodrigo Silva Nascimento Mancini
Rodrigo Silva Nascimento Mancini - 01.07.2022 01:49

What about returns or inputs with numpy?

Ответить
Phil Toa
Phil Toa - 19.05.2022 12:17

Thx.

Ответить
R Duck
R Duck - 18.05.2022 12:47

My brain are brokenn ;-;

Ответить
S0nic
S0nic - 18.05.2022 02:39

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

Ответить
Josef Hamelink
Josef Hamelink - 17.05.2022 23:15

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

Ответить
Krematory
Krematory - 17.05.2022 21:50

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

Ответить
Alperen GENÇOĞLU
Alperen GENÇOĞLU - 17.05.2022 21:27

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.

Ответить
Ayman Cassim
Ayman Cassim - 17.05.2022 18:41

Have you ever considered learning Rust? Nice video btw!

Ответить
Arijan Rahimic
Arijan Rahimic - 17.05.2022 17:07

Thank you very nice 👍🏼

Ответить
Mango
Mango - 17.05.2022 16:45

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

Ответить