Showing posts from July, 2018

Talk at the July ChennaiPy meetup

On the 28th, I gave a talk at the ChennaiPy meetup group on Dunder methods in Python. You can find the Jupyter Notebook that I used to present the content in Github.

To give you an overview of the talk, I introduced a number of dunder methods in Python, methods which provide functionality to make your custom objects mimic native Python objects.

If you didn't know, dunder is short for double underscore. A common dunder method that we all come across in Python classes is the `__init__` method, which is used to initialize an object during instantiation. Dunder methods are also called magic methods.

The dunder methods of interest are
`__repr__` and `__str__` : Provide the official and unofficial string representations of the Objects`__eq__`, `__lt__` and comparisons : Provide the functionality to compare custom Objects in Python.`__hash__` : Are used for operations on members of hashed containers like set, frozenset and dict.`__iter__` and `__next__` : Provide the functionality to cre…