3 ms·
Oh, neat, so I can stack them: foo = 'foo' print(f"{foo=!r:>20}") print(f"{foo.upper()=!r:>20}") The `=` you pointed out is a special case, however, and
by CGamesPlay 6y ago
Oh, neat, so I can stack them:
foo = 'foo'
print(f"{foo=!r:>20}")
print(f"{foo.upper()=!r:>20}")
The `=` you pointed out is a special case, however, and not part of the alignment specification. Sadly, this means that the above snippet is not as nicely formatted as I'd like. Still, it does seem useful for these cases:
print(f"{x=:.2f} {dx=:.2f} {dot_product=:.4f}")