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]): ... ```
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.
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
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
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]): ...
```
Awesome, a video about covariant/contravariant would be nice
I would also like a video on this.
Yes anthony that video would be great
@anthonywritescode this would be a great!
what about it specifically? i;d love to write about it
waiting for the 1 hour variance wideo *grabs popcorn
it's not _that_ complicated -- I just didn't want to get into it in this already-long video lol
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.
you're in luck, I've got just the video for ya: th-cam.com/video/-zH0qqDtd4w/w-d-xo.html
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"??
that's actually a really good analogy XD
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
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
yes but generally you don't want to do that since `tp.__getitem__` is very slow and has runtime overhead
Is there any value in making a method generic that doesn't take any parameters, but could return a variety of things?
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)
/me misreads title as "python Geriatrics (intermediate)"...don't mind me
This is awesome