__str__ vs __ repr__ in Just 60 Seconds

preview_player
Показать описание
__str__ vs __ repr__ in just 60 seconds in Python. #code #python #programming
Рекомендации по теме
Комментарии
Автор

Good video but you never showed what the output of repr was for comparison

chaddicusthegreat
Автор

I really like those shorts, keep them coming pls

simaobonvalot
Автор

__str__ has something to do with print function also. For seeing this, create an instance of the class in IDLE Shell (or in terminal, same folder as the class file). If you type "print(instance)" it will give the return of __str__, but if you just type "instance", it will return the representation. If you just type the name of the class, it will return <class '__main__.Car'>. ❤ Python

muriloous
Автор

Those shorts are really good. Just yesterday I saw just what I needed with the f-string to call %

cesarpereira
Автор

That’s like overriding the toString method in Java

GreatTaiwan
Автор

__repr__ should return a string that could be evaluated by eval.

niaei
Автор

The repr method would be nicer with a call super, but that’s the default anyway.

DrDeuteron
Автор

The monkey! I love it <3 and what @simaobonvalot said. Keep em coming. Could you possibly start compiling playlists?

cattelia
Автор

Couldn't find info on that very helpful

AkivaB
Автор

and me who doesn't even understand what "__inti__" is. doesn't matter how much I try

huh
Автор

What kind of users are you talking about, who are not developers?

cipherxen
Автор

Define repr without defining str and print what happens then?

Mestery