A Special Attributes and Methods
This appendix is a categorized list of all the special attributes and methods in the Python language. If you’re looking for a particular special method by name, see the index instead.
Complete documentation can be found at https://docs.python.org/3/reference/datamodel.html.
Special Methods
These methods are declared on a class to add support for various Python operators, built-in functions, and compound statements. These are all typically declared as instance methods, unless otherwise indicated.
Table A-1: Conversion and Coercion
Method | Typical purpose | Invocation |
obj.__bool__(self) |
Returns a boolean: ... |
Get Dead Simple Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.