Python's Magic Method __repr__ Tutorial - Automagically produce string representations of objects.

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

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

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

    Nice explanation of repr and magic methods. Thanks!

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

    Your teaching is very gppd and easy to understand, love it!

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

      Thanks!

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

      @@KrisJordan You are a God tier teacher, I wish I was in your class

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

    This is so helpful!! Pls keep uploading new videos :D

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

    Your videos are as outstanding as always. Thanks Kris.

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

    Thank you for your great video. One thing is confusing for me. You have used f"...." as the string. What type of string is it?

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

      Search for Python format/formatted string and you'll find quality introductions to it. They're great!

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

    Understood everything, except what is p0: Point = Point() and p0.x = 1.0.? like what is the Point doing and what is p0.x? so lost

    • @joshuacleveland-k4t
      @joshuacleveland-k4t 3 месяца назад

      I know this comment is a year old but:
      "p0: Point = Point()" is just instantiating the Point object and naming that point object "p0". The ": Point..." part is a type hint but not necessary. The line would do the same thing if it was just "p0 = Point()"
      the line "p0.x = 1.0" is redefining the value of attribute x in the p0 object just made. Its value was 0.0, but was changed to 1.0 in this line. You can access an objects attributes by typing the object name, a period, then the attribute name. So p0, period, then x.
      hope this helped

  • @kannalix-amsmhss4369
    @kannalix-amsmhss4369 3 года назад +1

    how are you, man!

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

    You've confused the purpose of dunder repr with that of dunder str.
    They are not the same and your usage and explanation of dunder repr here is incorrect.
    Best of luck.