JuliaIO / Formatting.jl

Deprecated. See README. (A Julia package to provide Python-like formatting support)
Other
131 stars 23 forks source link

Support python style f"{x:0.2}" #41

Open innerlee opened 7 years ago

innerlee commented 7 years ago

In python, the following style is convenient:

>>> x = 1.234
>>> f"{x:0.2}"
'1.23'

It would be great if we

ScottPJones commented 6 years ago

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).

ludwigwinkler commented 4 years ago

Hi,

any update on the f-string style formatting?

Thanks for your effort!