Python Tip #240 (of 365): Dunder methods are meant to be defined, but not called...
Trey Hunner ๐ @treyhunner@mastodon.social
Python Tip #240 (of 365):
Dunder methods are meant to be defined, but not called.
Do this:
str(today)
Not this:
today.__str__()
Why avoid calling dunder methods?
Mostly because you're not supposed to.
Dunder methods are a contract between Python and whoever wrote the class: Python calls them, we use the operations they power.
๐งต (1/3)