Closed
Description
Old string formatting has no support for complex numbers:
>>> "%f" % (1+0j)
Traceback (most recent call last):
File "<python-input-0>", line 1, in <module>
"%f" % (1+0j)
~~~~~^~~~~~~~
TypeError: must be real number, not complex
But formatted string literals and str.format() have:
>>> f"{1+0j:f}"
'1.000000+0.000000j'
>>> f"{1+0j:}"
'(1+0j)'
>>> f"{1.:}" # default formatting slightly different than for floats
'1.0'
Unfortunately, formatting rules for complexes aren't documented in the Format Specification Mini-Language section. I'll work on a patch.