Type Hinting Makes Your Code More Professional

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024
  • НаукаНаука

Комментарии • 17

  • @alperengencoglu5367
    @alperengencoglu5367 2 года назад +5

    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.

  • @Delirium132231
    @Delirium132231 2 года назад +2

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

  • @Hoco30
    @Hoco30 14 дней назад

    Thanks you always have something that I needed.

  • @josefhamelink6049
    @josefhamelink6049 2 года назад +2

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

    • @sasidharnaidu4507
      @sasidharnaidu4507 Год назад

      Yes, best thing is to make mypy kind of module inbuilt in standard lib

  • @yoavmor9002
    @yoavmor9002 10 месяцев назад

    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]

  • @xrdgx1
    @xrdgx1 2 года назад +1

    What about returns or inputs with numpy?

  • @arijanrahimic3210
    @arijanrahimic3210 2 года назад

    Thank you very nice 👍🏼

  • @1202loki
    @1202loki 2 года назад +1

    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

  • @aymancassim8944
    @aymancassim8944 2 года назад +1

    Have you ever considered learning Rust? Nice video btw!

    • @notnalin
      @notnalin 2 года назад

      He has rust tutorials

    • @aymancassim8944
      @aymancassim8944 2 года назад

      @@notnalin Really where?

    • @notnalin
      @notnalin 2 года назад

      @@aymancassim8944 ruclips.net/p/PLzMcBGfZo4-nyLTlSRBvo0zjSnCnqjHYQ

  • @philtoa334
    @philtoa334 2 года назад

    Thx.

  • @MangoNutella
    @MangoNutella 2 года назад +4

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

  • @rduck9097
    @rduck9097 2 года назад

    My brain are brokenn ;-;