Python Typing Generics and Python 3.11 Variadic Generics

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • A tutorial on Generics with Python typing including Variadic Generics, a feature in Python 3.11.
    This tutorial will show you how to make TypeVar variables, how to use them in functions and classes and how VS Code with Pylance shows you how the types are used.
    Source Code: github.com/ton...
    Tutorial on setting up VS Code: realpython.com...
    Link help to my setup: realpython.com...

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

  • @JayJay-ki4mi
    @JayJay-ki4mi Год назад +7

    For anybody wondering the theme is called Noctis.

  • @paschalokafor9043
    @paschalokafor9043 Год назад +4

    I recommend this video for any who wants to learn generic types in any language. For months I have struggled to grasp the concept. But now its really clear. Thank you.

  • @kazsm9666
    @kazsm9666 Год назад +5

    This is a truly valuable explanation of generics, one of the best i've seen. Thank you for that!

  • @beckyamsel2997
    @beckyamsel2997 Год назад +2

    Incredibly helpful explanation!! Can't thank you enough! The way you highlight the problem and then show how to solve it leaves no question of "when would I use this?" in the way my lecture at uni did.

  • @paulweveritt
    @paulweveritt Год назад +7

    Loved this video. Watched it carefully. Might set a reminder to watch it again in a month.
    All stuff I need to know but didn't. Perfect presentation style. Lots of Python typing stuff seems aimed at people coming from Java or C#. Thanks a bunch, Anthony.

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

      i love it cuz he remind me of c# and how organized it was python is so messy :D

  • @YashDesai95
    @YashDesai95 Месяц назад

    You might be Excommunicado for using light themes. but your contribution to society will never be forget. keep posting such awesome content. Yeah

  • @DevendraSingh-bk7sv
    @DevendraSingh-bk7sv Год назад +4

    Great video sir..... I understood the concepts of Generics very well...

  • @hasnainkhattak6002
    @hasnainkhattak6002 Год назад +1

    great video bro ......first video which really gives me a good understanding of python generics

  • @vaha2833
    @vaha2833 11 месяцев назад +1

    I may need to check my doctor after this video >_>

  • @DarylStark
    @DarylStark 7 месяцев назад

    This was a life saver! So clear and so helpful!

  • @AbnerAlvarado
    @AbnerAlvarado 5 месяцев назад

    More videos! Do you know about processing and threading? Drop a video about it! 🙌🏼

  • @mj2068
    @mj2068 8 месяцев назад

    very very well explained, thanks Anthony, i totally get it now.

  • @alemswazzu
    @alemswazzu 3 месяца назад +1

    Why did you annotate the types in the class twice?

  • @louidominicnaquita7723
    @louidominicnaquita7723 8 месяцев назад

    Very helpful video! What color theme do you use btw?

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

    Thank you. Well done as usual.

  • @igoromelchenko3482
    @igoromelchenko3482 Год назад +1

    very educative, thanks

  • @mahdi-hasan
    @mahdi-hasan 10 месяцев назад

    Thanks for blinding me.

  • @jakubl8271
    @jakubl8271 5 месяцев назад

    Ok about TypeVar, yet there may be a time for finding out difference between class variables and instance variables?

  • @mykun8737
    @mykun8737 Год назад +2

    Could you tell me what themes you used on vs code, i saw beautifully

  • @miguelfasanella6042
    @miguelfasanella6042 11 дней назад

    I feel like I just unlocked a new skill in a videogame

  • @mateuszsmendowski2677
    @mateuszsmendowski2677 Год назад +1

    Great!🎉

  • @Patrick-hl1wp
    @Patrick-hl1wp Год назад

    awesome explanation, thanks

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

    great work boss.

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

    What is your zsh theme, sir?

  • @furkanonder-ut4mz
    @furkanonder-ut4mz Год назад

    Awesome!

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

    Great video, I have always wondered what the Generics and Variadic Generics where! One question I didn't get any answer to though. In the last example, can I create for example record2 with separate types or do the typing information get set when you create the first instance?
    I.e. Can I:
    record1 = Record(1, "Hello", 12.3, 1234)
    record2 = Record(1, 12.3, "Hello")
    Would this raise typing issues, or would the IDE/typing system successfully separate between the two objects? I do understand that it probably is really bad practice to do something like this, it is purely for understanding the limitations!

    • @AnthonyShaw
      @AnthonyShaw  Год назад +1

      that would be perfectly valid. The typing information applies to the instance in that case

    • @AnthonyShaw
      @AnthonyShaw  Год назад +2

      record1 = Record(1, "Hello", 12.3, 1234) # Record[int, str, float, int]
      record2 = Record(1, 12.3, "Hello") # Record[int, float, str]
      record2.update(12.3, "Hello") # OK
      record1.update("new word", 123., 32343) #OK

  • @RaymondLee-hl8th
    @RaymondLee-hl8th Год назад +2

    Awesome! But can you show how to enable the inline pylance warning?

  • @blackcatdevel0per
    @blackcatdevel0per Год назад +2

    11:25 Use dataclasses

  • @bruh-jr6wj
    @bruh-jr6wj 10 месяцев назад

    My eyes...

  • @i007c
    @i007c 11 месяцев назад

    white theme 🤣

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

    Dear mathematicians, please note that being good at math doesn't make one an engineer of softwre. Writing generics like this sounds like pain on a whole new level. I would rather use C++ templates than this. Generics themselves are a seperate set of parameters. Functions have value and type parameters, no more and no less. This is one of those cases where python just lacs intuitive support.

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

    How to get inline view of problem like you have on 1:40?

    • @AnthonyShaw
      @AnthonyShaw  Год назад +1

      An extension called 'error lens' marketplace.visualstudio.com/items?itemName=usernamehw.errorlens