THIS Makes Your Python Classes More READABLE

preview_player
Показать описание
This makes your Python classes more readable. #code #python #programming
Рекомендации по теме
Комментарии
Автор

I hate that youtube does not allow me to save shorts to a folder called “cool python things to know”

classmanOfficial
Автор

Ah yes, the Banana Meth.... We have to

tinahalder
Автор

You can also use __repr__ for displaying within lists etc. I usually do __repr__ = __str__

INGIE
Автор

10.5 euros for one banana?

damn inflation these days

fgrey-
Автор

Good to see meth1 and meth2 are blue. Good work, Jesse

deldarel
Автор

And then I tell them that banana better have diamonds inside for that price... 😂

erikkonstas
Автор

Hmm perhaps you could write after your paramater that you describe in the __init__ after self, as for example
name:str
This allows you to not write __str__ but you give the conputer command of making it as a str
Its more easier to read
More organized

But again the __str__ method looks more cooler so its your choice

Divine
Автор

Super handy for debug purposes (though I am starting to have a preference for making a "debug(self)" method for that these days).

ConstantlyDamaged
Автор

__repr__ is what I’ve started using but I forgot why

JordanMetroidManiac
Автор

I always love the idea of being able to customize the printing of classes. Its unfortunate that I always forget to though 🤦‍♂️

bradleyalbright
Автор

This channel is amazing...Good place to learn..thank you Sir

RamMohan-xuey
Автор

equivalent of the toString() method in java

stephenpeters
Автор

The banana has 2 whole meths in it. Gigamethamphetamines

NobsiBonswa
Автор

What's the methd1 n 2 doing?
Someone explain 🙏

cocoatea
Автор

2023: Python developers find "to string" function, evolution in progress...

KonstantinSemenow
Автор

You can also use the dunder repr method

qwerty_qwerty
Автор

Can this also be done using a class level decorator?

manolomonetha
Автор

i just realized meth is short for method and not methamphetamine

basilicon.
Автор

That's is a wrong use case of dunder __str__, what you are trying to do it should be done in dunder __repr__ not dunder __str__

martim
Автор

Use the long original name: ❌
Use an addictive drug: 😎✅💵

nitlixis