Тёмный

python Generics (intermediate) anthony explains  

anthonywritescode
Подписаться 42 тыс.
Просмотров 16 тыс.
50% 1

Опубликовано:

 

26 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@sadhlife
@sadhlife 2 года назад
random trivia I learned recently: to make a generic protocol class, you can do: ``` class C(Protocol, Generic[T]): ... ``` which is a bit much, so there's a shorthand: ``` class C(Protocol[T]): ... ```
@gabrielmota3583
@gabrielmota3583 2 года назад
Awesome, a video about covariant/contravariant would be nice
@AceofSpades5757
@AceofSpades5757 2 года назад
I would also like a video on this.
@venkateshhariharan4341
@venkateshhariharan4341 2 года назад
Yes anthony that video would be great
@AlexanderSuraphel
@AlexanderSuraphel 2 года назад
@anthonywritescode this would be a great!
@dibri
@dibri Месяц назад
what about it specifically? i;d love to write about it
@sadhlife
@sadhlife 2 года назад
waiting for the 1 hour variance wideo *grabs popcorn
@anthonywritescode
@anthonywritescode 2 года назад
it's not _that_ complicated -- I just didn't want to get into it in this already-long video lol
@byte__3076
@byte__3076 2 года назад
If I remember correctly, you don't need necessarily to type annotate the constructor if you say so: my_object = FDict[str, int]() In this case, it makes no sense but still, you can. BTW good video, and a very interesting topic
@anthonywritescode
@anthonywritescode 2 года назад
yes but generally you don't want to do that since `tp.__getitem__` is very slow and has runtime overhead
@dhruvakashyap
@dhruvakashyap 2 года назад
I remember my professor talking about covariate and contravariant types and all I remember is that "a bag of apples is not a bag of fruits"??
@sadhlife
@sadhlife 2 года назад
that's actually a really good analogy XD
@anthonywritescode
@anthonywritescode 2 года назад
indeed that's part of the story -- most of my framing is with c# `out` / `in` parameters (though generics are similar as well) -- immutability also comes to the table
@jbrnds
@jbrnds 2 года назад
I have a question for you, @anthonywritescode. I am in a continuous merge request review discussion back and forth with others regarding the use of `NoReturn` vs `None` for the return of a function or method that does not returns anything. Can you please shine your light on it? Docs state then the `NoReturn` is used for functions that are not expected to return anything; eg. an Exception raising function.
@anthonywritescode
@anthonywritescode 2 года назад
you're in luck, I've got just the video for ya: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE--zH0qqDtd4w.html
@DavidDellsperger
@DavidDellsperger 2 года назад
/me misreads title as "python Geriatrics (intermediate)"...don't mind me
@veloz7860
@veloz7860 Год назад
Is there any value in making a method generic that doesn't take any parameters, but could return a variety of things?
@anthonywritescode
@anthonywritescode Год назад
that's not generic. a generic return value must be based on a parameter. you've got a union return (which is sort of a smell)
@akrylic_
@akrylic_ 2 года назад
This is awesome
Далее
Generics are VITAL in typed Python
16:54
Просмотров 10 тыс.
ITZY 예지한테 AI 메이크업하기💖 #shorts
00:23
python descriptors! (advanced) anthony explains #519
19:04
Learn TypeScript Generics In 13 Minutes
12:52
Просмотров 275 тыс.
Python 3.12 Generic Types Explained
18:27
Просмотров 62 тыс.
5 Useful Python Decorators (ft. Carberra)
14:34
Просмотров 104 тыс.
ITZY 예지한테 AI 메이크업하기💖 #shorts
00:23