
You want to learn more about them?



They're called dunder methods because of double under score at the beginning and at the end of their name
Class that implements them can mimic behavior of built-in types like int, str, list, ...

It's used to construct objects from class A - a constructor
You can define which arguments it takes
Inside it attributes of newly created instance are set

__str__ - this one is used when conversion to string is requested - printable representation
__repr__ - official representation, it's great if you can just copy it to your code to create new object with the same values

__eq__ - a == b
__ne__ - a != b
__lt__ - a < b
__gt__ - a > b
__le__ - a <= b
__ge__ - a >= b
__add__ - a + b
...
You also need to implement them if you want to make your objects sortable

__getitem__ - a['key']
__setitem__ - a['key'] = 'value'

https://docs.python.org/3/reference/datamodel.html