Python Generics ⇢ Make FirstOrDefault method with type hints

Описание к видео Python Generics ⇢ Make FirstOrDefault method with type hints

The FirstOrDefault method in C# returns the first element from a list that satisfies a predicate, or returns the type default value. This can work because C# lists are generic. Python is not typed and still you can use generics and in this video, you learn how to create a generic first_or_default method in Python

C H A P T E R S
0:00 Lists and FirstOrDefault in C# are generic
1:10 Generator expression to filter lists
1:50 next function with default value
3:15 Type Hints and Generics in Python
3:50 Generic Python class
5:22 Getting the generic type at runtime
6:45 Annotating callable
7:40 Cannot instantiate Generic custom class that has parameters
9:20 Optional return type

M Y O N L I N E T R A I N I N G
🎓Like my style of teaching? Enroll in one of my courses online: https://www.pythonforeveryone.com

#FirstOrDefault #first_or_default #python

Комментарии

Информация по комментариям в разработке