Skip to content Skip to sidebar Skip to footer
Showing posts with the label Magic Methods

How To Override A Magic Method For The Current Script Without A Class?

How to override a magic method for the current script? def __setattr__(name, value): __dict__[n… Read more How To Override A Magic Method For The Current Script Without A Class?

Why Are Explicit Calls To Magic Methods Slower Than "sugared" Syntax?

I was messing around with a small custom data object that needs to be hashable, comparable, and fas… Read more Why Are Explicit Calls To Magic Methods Slower Than "sugared" Syntax?

Defining Magic Methods On Classes

I would like to define a single object that can be iterated over without having to create a class a… Read more Defining Magic Methods On Classes

Where Is The Python Documentation For The Special Methods? (__init__, __new__, __len__, ...)

Where is a complete list of the special double-underscore/dunder methods that can be used in classe… Read more Where Is The Python Documentation For The Special Methods? (__init__, __new__, __len__, ...)