I dislike Python’s native string for complex numbers, and so wrote my own:
def str (z):
result = f"{z.a}"
if (z.b < 0.0):
result += " - "
else:
result += " + "
result += f"{abs(z.b)}i"
return result
I saw the article here about overriding a function at the instance level, but is it possible to override str in complex’s class? That is, any complex number I instance would use my str function?