Type Hints in Python: What, Why, and How
HTML-код
- Опубликовано: 31 авг 2021
- In this video I talk about annotating your functions and variables with type hints in Python and why you should do it.
Need one-on-one help with your project? I can help through my coaching program. Learn more here: prettyprinted.com/coaching
Typing documentation: docs.python.org/3/library/typ...
Type hints cheat sheet: mypy.readthedocs.io/en/stable...
Get the code here: prettyprinted.com/l/P7j
Twitter: / pretty_printed
Github: github.com/prettyprinted
i have seen people teaching how to use type hints but never felt important before seeing this video. great video!
At minute 14:00, in Python 3.11, we will be able to write Self for the return value rather than "User" which will be handy. Thanks for the video!
Video was maybe a bit longer than it needed to be but much better than the 'just do this' explanation I got elsewhere! I can see how this will make my code more readable to others and importantly to tools, which will be able to parse this information reliably compared to the human-readable docstrings
Yeah, while planning I realized that the video was longer than I would have wanted, but I didn't want to take the time to make it shorter. :)
Thanks for watching!
14 minutes too long; devolves into rambling
Very nice video. You are huge inspiration man
Emphasize readability, Wonderful! Hope may have some time to talk SOLID design principles and common design patterns in Python in near future.
Great video!
It would be great if you made videos on sqlachemy with fastapi. There realy isn't a lot out there on this topic and fastapi is getting more and more popular. I know a lot of the code is very similar to sqlalchemy with flask, but those minor differences do make it confusing.
I need circular module dependency in order to use type hint. How to safely avoid that ? Button class needs Window class and Window class needs Button class. Do I need to use typing.TypeVar() ?
Are you allowed to have 2 functions with same name in Python? Which one will be called then?
Sir , How Can I reach out to You , I really need your help.
Please Reply
Thanks, excellent. Do you have a video about annotations?
Well the type hints I demonstrated in the video are done through annotations. Do you mean something more specific?
@@prettyprinted Oh sorry, I was referring to decorators not annotations. Did you create a video about them?
❤❤
Make more videos bro!
Working on it!
LOL at saying stir instead of string for str.
You have misspelled my name! 😉 It's "Per Persson", not "per person".