Type Hinting Makes Your Code More Professional

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • In this video we learn why type hinting makes your Python code more professional and how to do it.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine.com/books/
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/
    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
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 16

  • @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

  • @arijanrahimic3210
    @arijanrahimic3210 2 ปีที่แล้ว

    Thank you very nice 👍🏼

  • @yoavmor9002
    @yoavmor9002 7 หลายเดือนก่อน

    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?

  • @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

  • @philtoa334
    @philtoa334 2 ปีที่แล้ว

    Thx.

  • @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

  • @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 th-cam.com/play/PLzMcBGfZo4-nyLTlSRBvo0zjSnCnqjHYQ.html

  • @rduck9097
    @rduck9097 2 ปีที่แล้ว

    My brain are brokenn ;-;

  • @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.

    • @oguzhantopaloglu9442
      @oguzhantopaloglu9442 2 ปีที่แล้ว +2

      i think it's fine, i mean most people skip it anyways :P