python Generics (intermediate) anthony explains

  Рет қаралды 16,230

anthonywritescode

anthonywritescode

Күн бұрын

Пікірлер: 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 2 ай бұрын
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
@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: kzbin.info/www/bejne/Y6urYaSnedmXatk
@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
@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)
@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
@DavidDellsperger
@DavidDellsperger 2 жыл бұрын
/me misreads title as "python Geriatrics (intermediate)"...don't mind me
@akrylic_
@akrylic_ 2 жыл бұрын
This is awesome
babi+ast helped me not break sentry! (intermediate) anthony explains #431
12:30
python descriptors! (advanced) anthony explains #519
19:04
anthonywritescode
Рет қаралды 18 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Generics are VITAL in typed Python
16:54
Carberra
Рет қаралды 11 М.
Python Typing Generics and Python 3.11 Variadic Generics
22:31
Anthony Shaw
Рет қаралды 18 М.
oops I'm the pyuwsgi maintainer now (intermediate) anthony explains #579
22:55
Python dataclasses will save you HOURS, also featuring attrs
8:50
python TypeGuard (PEP 647) (intermediate) anthony explains #439
11:04
anthonywritescode
Рет қаралды 5 М.
Lambda in a Loop is a Code Smell
8:20
mCoding
Рет қаралды 62 М.
debugging a broken cache!
21:16
anthonywritescode
Рет қаралды 4,2 М.
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН