Next / Previous / Contents / TCC Help System / NM Tech homepage

26.3.13. __format__: Implement the format() function

Use this special method to determine how an instance of your class acts when passed to the function described in Section 20.16, “format(): Format a value”. The calling sequence is:

    def __format__(self, fmt):

The interpretation of the fmt argument is entirely up to you. The return value should be a string representation of the instance.

If the call to the format() function does not provide a second argument, the fmt value passed to this method will be an empty string.