Support python style f"{x:0.2}"
In python, the following style is convenient:
>>> x = 1.234
>>> f"{x:0.2}"
'1.23'
It would be great if we
- can write variable inside brackets
- support string prefix
f"some string with formats"to do this formatting
A type of f"some string with formats" is already supported in the StringLiterals package. The syntax isn't quite the same as the Python syntax, that is something that I'd like to make closer, if possible.
I tried your example, however, it needed to be changed to work as you showed:
f"{x:0.2f}" returns '1.23', but f"{x:0.2}" returns '1.2'
Currently, for StringLiterals, you need to have f"\{0.2f}(x), as stated in the README, I'd like to make that closer to the Python syntax, so that the only difference would be the leading backslash (which is important to keep formatting operations from interfering with normal string syntax).
Hi,
any update on the f-string style formatting?
Thanks for your effort!