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...
For anybody wondering the theme is called Noctis.
Thanks was looking for this
It looks anything but “nocturnal”.
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.
Wow thank you!!
This is a truly valuable explanation of generics, one of the best i've seen. Thank you for that!
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.
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.
i love it cuz he remind me of c# and how organized it was python is so messy :D
You might be Excommunicado for using light themes. but your contribution to society will never be forget. keep posting such awesome content. Yeah
Great video sir..... I understood the concepts of Generics very well...
great video bro ......first video which really gives me a good understanding of python generics
I may need to check my doctor after this video >_>
This was a life saver! So clear and so helpful!
More videos! Do you know about processing and threading? Drop a video about it! 🙌🏼
very very well explained, thanks Anthony, i totally get it now.
Why did you annotate the types in the class twice?
Very helpful video! What color theme do you use btw?
Thank you. Well done as usual.
very educative, thanks
Thanks for blinding me.
Ok about TypeVar, yet there may be a time for finding out difference between class variables and instance variables?
Could you tell me what themes you used on vs code, i saw beautifully
Same!
The theme is called Noctis.
I feel like I just unlocked a new skill in a videogame
Great!🎉
awesome explanation, thanks
great work boss.
What is your zsh theme, sir?
Awesome!
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!
that would be perfectly valid. The typing information applies to the instance in that case
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
Awesome! But can you show how to enable the inline pylance warning?
Error Lens extension
11:25 Use dataclasses
My eyes...
white theme 🤣
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.
How to get inline view of problem like you have on 1:40?
An extension called 'error lens' marketplace.visualstudio.com/items?itemName=usernamehw.errorlens