The root cause of this problem is object.__format__, which is basically:
def __format__(self, fmt):
return str(self).__format__(fmt)
So here we're changing the type of the object (to str) but still keeping
the same format string. That doesn't make any sense: the format string
is type specifi
Eric Smith wrote:
This code works on 2.6 and 3.0:
>>> format(1+1j, '10s')
'(1+1j)'
That's because format ends up calling object.__format__ because complex
doesn't have its own __format__. Then object.__format__ calls str(self)
which returns '(1+1j)'. So the original call basically tur
This code works on 2.6 and 3.0:
>>> format(1+1j, '10s')
'(1+1j)'
That's because format ends up calling object.__format__ because complex
doesn't have its own __format__. Then object.__format__ calls str(self)
which returns '(1+1j)'. So the original call basically turns into
"format('(1