Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

printfmt("{:,}", 1234) doesn't print as 1,234 #17

Open
lewisl opened this issue Apr 27, 2016 · 3 comments
Open

printfmt("{:,}", 1234) doesn't print as 1,234 #17

lewisl opened this issue Apr 27, 2016 · 3 comments

Comments

@lewisl
Copy link

lewisl commented Apr 27, 2016

It is shown clearly as an actual example in the Python formatting specification shown. It doesn't work.

@ScottPJones
Copy link
Collaborator

It looks like support for commas was never actually implemented for the Python formatting functions.
It does work in JuliaString/Format.jl, using the C format function, or the generic fmt function
(note the renaming in that package, fmt -> pyfmt, sprintf1 -> cfmt, and a new generic fmt function)

@jtrakk
Copy link

jtrakk commented Aug 24, 2021

To give an example, this form works in Python but not Julia. I don't succeed with fmt either.

Python:

In [2]: "{:,}".format(123456)
Out[2]: '123,456'

Julia:

julia> printfmt("{:,}", 123456)
123456
julia> fmt(FormatSpec(","), 123456)
"123456"

@ScottPJones
Copy link
Collaborator

https://github.com/JuliaString/Format.jl does handle commas.
fmt(123456, :commas) will return 123,456

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants