Build Status | Code Coverage |
---|---|
The JuFormatting package provides the usefull formatting syntax from python in both a function form and a f-string using the @f_str macro. The JuFormatting library is fully written in julia and works for versions greater or equal to julia 1.4.
In a Julia session, after entering the package manager mode with ]
, run the command
pkg> update
pkg> add https://github.com/antcap96/JuFormatting.jl
After installing the package, you can start using it
using JuFormatting
The module dives access to two ways of formatting a string, using the format
function and using the @f_str
macro allows python's f-string style formatting.
julia> format("{:#b}", 3)
"0b11"
julia> f"{31.32:10.3g}"
" 31.3"
-
the "n" and "," formating type is not implemented for Integers nor floats.
-
getattr and getindex are not yet supported in the format syntax
-
replacement fields in format specifiers are not yet supported
-
current support for strings does not allow to set width
-
julia offers more numeric types than python, currently all abstract floats are handled the same and so do all integers.
-
Inf
andNaN
are formated diferently from python to match julia default conversion to string of these values. -
julia starts using the exponent notation for floats at 1e6 while python only starts using this notation at 1e15, so an empty format
"{}"
will give diferent results from python