I have this code snippet:
using Formatting
printfmtln("{} total RAM", format(Sys.total_memory(), precision=2, autoscale=:binary))
which nicely prints what I expected:
15.56Gi total RAM
Is there a way to pack both formatting parameters precision=2, autoscale=:binary
into the first item’s placeholder {}
?
Do you mean something like:
println("$(format(Sys.total_memory(), precision=2, autoscale=:binary)) total RAM")
1 Like
tk3369
June 18, 2020, 3:16pm
3
I don’t think so. If you check the source code, the format spec mimics the Python format library. Specifically, autoscale
isn’t supported. Precision is OK though.
It’s an interesting variation, but I meant something like this:
printfmtln("{:.2f, autoscale=:binary} total RAM", Sys.total_memory())
I know, I know - make a pull request.
1 Like