MENU

Fun & Interesting

Generics are VITAL in typed Python

Carberra 12,966 8 months ago
Video Not Working? Fix It Now

Generics are a slightly odd (at first) but incredibly useful part of Python's type system that allow you to create a single typed interface, then provide specific types as and when you need to. They also give square brackets a good workout! 00:00 - Intro 00:44 - TypeVar primer [1] 03:35 - Illustrative example [2-3] 08:37 - Inferencing generic types using overloads [4-5] 16:30 - Outro [1] https://docs.python.org/3/library/typing.html#typing.TypeVar [2] https://docs.python.org/3/library/typing.html#typing.Generic [3] https://github.com/Carberra/python-is-awesome/tree/main/2418-generics [4] https://youtu.be/l0T4jvuP0H8 [5] https://docs.python.org/3/library/typing.html#typing.overload — If you want to see more of me, join my Discord server! https://discord.gg/5vVgQpK I get a lot of people asking, so here's my setup! • Visual Studio Code: https://youtu.be/PBQspYkkksU • Terminal: https://youtu.be/4RuGK3w6Mbs • Desk/recording gear: https://kit.co/Carberra • PC build: https://uk.pcpartpicker.com/list/TmzGYN Affiliations (I may earn a commission): • Codecrafters -- 40% off any plan: https://app.codecrafters.io/join?via=parafoxia • Keeper Password Manager -- 30% off your first year: https://keeper.io/r/EX4FB1C — If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so. #python #coding #howto

Comment