the ability to define a generic type of behavior that will (potentially) behave differently when applied to different types
Python is very polymorphic in nature.
It does not matter if the collection is a list, a tuple, a dictionary or a generator.
Only care about is that it supports the iterable protocol
+, -, *, /
We can add support to our own classes for the + operator by implementing:
_ _ add _ _ method
Special Methods
Start double underscore and End double underscore: dunder methods.
Never use this naming atandard for your own methods or attributes - not guarantee won’t break in the future.
ex: _ _ my_function _ _ = (don’t use)
“”might misunderstanding this as a python things, not a custom codes””.
other special methods:
_ _ init _ _
_ _ enter _ _ : context managers, ctx( )
_ _ getitem_ _: sequence tyoes
_ _ iter_ _: iterables and iterators
_ _ len _ _: implement len( )
both used for creating a string
_ _ repr _ _ is used by developers
_ _ str _ _ is used by str ( ) and print ( ), as well as various formating functions
if neither is implemented and since all objects inherit from Object, will use _ _ repr _ _ defined there instead