In Julia 1.6 you can use Printf.Format
, and then Printf.format
instead of the macro:
julia> f = Printf.Format("%9.3f "^4);
julia> Printf.format(f, 1,2,3,4)
" 1.000 2.000 3.000 4.000 "
julia> Printf.format(stdout, f, 1,2,3,4)
1.000 2.000 3.000 4.000
(Well, there is an unwanted trailing space in this example, but this can be easily worked around with other ways of making the format string.)