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

Комментарии • 20

  • @tazkhan8679
    @tazkhan8679 2 года назад +1

    i have seen people teaching how to use type hints but never felt important before seeing this video. great video!

  • @khmsalhuas1
    @khmsalhuas1 2 года назад +2

    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!

  • @kiri101
    @kiri101 2 года назад +3

    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

    • @prettyprinted
      @prettyprinted  2 года назад

      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!

    • @0x007A
      @0x007A 2 года назад

      14 minutes too long; devolves into rambling

  • @SsaliJonathan
    @SsaliJonathan 2 года назад +1

    Very nice video. You are huge inspiration man

  • @goodwish1543
    @goodwish1543 2 года назад

    Emphasize readability, Wonderful! Hope may have some time to talk SOLID design principles and common design patterns in Python in near future.

  • @petarkasapinov7324
    @petarkasapinov7324 2 года назад

    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.

  • @kcvinu
    @kcvinu Год назад

    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() ?

  • @atexnik
    @atexnik Год назад

    Are you allowed to have 2 functions with same name in Python? Which one will be called then?

  • @jabiraziz1219
    @jabiraziz1219 2 года назад

    Sir , How Can I reach out to You , I really need your help.
    Please Reply

  • @DerMaikNichJa
    @DerMaikNichJa 2 года назад

    Thanks, excellent. Do you have a video about annotations?

    • @prettyprinted
      @prettyprinted  2 года назад

      Well the type hints I demonstrated in the video are done through annotations. Do you mean something more specific?

    • @DerMaikNichJa
      @DerMaikNichJa 2 года назад

      @@prettyprinted Oh sorry, I was referring to decorators not annotations. Did you create a video about them?

  • @AnkitTiwari-dq7qm
    @AnkitTiwari-dq7qm 2 года назад

    ❤❤

  • @bartekz88
    @bartekz88 2 года назад

    Make more videos bro!

  • @Steven-wm9vu
    @Steven-wm9vu 2 года назад

    LOL at saying stir instead of string for str.

  • @md2perpe
    @md2perpe 2 года назад +1

    You have misspelled my name! 😉 It's "Per Persson", not "per person".