It is used when you pass an integer to the format () function. Details elude me, because I cannot get him to tell me what the argument is. (Edit: see Link with a lost theory)
Oh, and it only works when the only argument is an integer. If you pass a tuple for formatting, the tuple .__ format__ and int .__ str__ function are called or something.
'{0}'.format(4) str(4.__format__(format_spec=''))
source share