Skip to main content

One doc tagged with "dunder-methods"

View all tags

Magic Methods (Dunder Methods): `__len__`, `__getitem__`, and More

We've already encountered some of Python's special "dunder" (double underscore) methods, like init, str, and repr. These methods are special because we don't call them directly (e.g., myobj.str()). Instead, Python calls them for us in response to specific actions, like print(myobj).