Printf with variable format string

thanks so much @Paul_Soderlind !

since format is not exported, and so isn’t documented, here’s specifically what i got to work:

julia> using Printf

julia> w=9
9

julia> fmt = Printf.Format("%$(w)d")
Printf.Format{Base.CodeUnits{UInt8, String}, Tuple{Printf.Spec{Val{'d'}}}}(UInt8[0x25, 0x39, 0x64], UnitRange{Int64}[1:0, 4:3], (%9.0d,))

julia> Printf.format(stdout, fmt,16)
       16
2 Likes