Also check out https://github.com/ScottPJones/StringUtils.jl, which is an
extension of Formatting.

On Sunday, March 13, 2016, Greg Plowman <greg_plow...@yahoo.com.au> wrote:

> I am trying to find an easy way to format numbers with thousands
> separators.
> It seems the package Formatting can be used for this.
>
> However, I can't seem to get the "python-style" format specifier working.
> Below the FormatSpec is correctly created with the field tsep = true, but
> it appears to have no effect when printing using printfmt.
>
> julia> fspec = FormatSpec(",d")
> Formatting.FormatSpec
>   cls   = i
>   typ   = d
>   fill  =
>   align = >
>   sign  = -
>   width = -1
>   prec  = -1
>   ipre  = false
>   zpad  = false
>   tsep  = true
>
> julia> printfmt(fspec, 10^9)
> 1000000000
>
>
> Similarly for FormatExpr ...
>
> fexpr = FormatExpr("{:,d}")
> printfmt(fexpr, 10^9)
> 1000000000
>
> Am I doing something wrong? Or is this not yet implemented?
>
>
> I do realise I can use sprint1 with println or @printf, but I was looking
> to use something more "inline".
>
> @printf("x = %s\n", sprintf1("%'i", x))
>
>

Reply via email to