bicycle1885 / Fmt.jl

Python-style format strings for Julia
MIT License
40 stars 3 forks source link

Allow full spec as string #3

Open t-bltg opened 2 years ago

t-bltg commented 2 years ago

In Python, we are allowed to interpolate the format as a string, (useful when used across the whole program):

>>> fmt = '.4g'
>>> x = 3.14159
>>> f'{x:{fmt}}'
'3.142'

This PR allows to do the following:

julia> using Fmt
julia> fmt = ".4g";
julia> x = 3.14159;
julia> f"{$x:{$fmt}}"
"3.142"

Maybe there's a better way to enhance this, but for now it works :)

t-bltg commented 2 years ago

@bicycle1885, would it be possible to review this PR and https://github.com/bicycle1885/Fmt.jl/pull/4 ?

Thanks !

t-bltg commented 1 year ago

@bicycle1885, bump.