Custom formatting for a class
suggest changeNote:
Everything below applies to the str.format method, as well as the format function. In the text below, the two are interchangeable.
For every value which is passed to the format function, Python looks for a __format__ method for that argument. Your own custom class can therefore have its own __format__ method to determine how the format function will display and format your class and its attributes.
object.__format__(self, format_spec)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents