StrFormat
Julia Version | Unit Tests | Coverage |
---|---|---|
Julia Latest |
The following extra format sequences (see StrLiterals for the full specification) are added:
-
\%<ccc><formatcode>(arguments)
is interpolated as a call tocfmt("<cccc><formatcode>",arguments)
, where<ccc><formatcode>
is a C-style format string. -
\%(arguments)
is interpolated as a call tofmt(arguments)
. This is especially useful when defaults have been set for the type of the first argument. -
fmt_default!{T}(::Type{T}, syms::Symbol...; kwargs...)
sets the defaults for a particular type. -
fmt_default!(syms::Symbol...; kwargs...)
sets the defaults for all types.
Symbols that can currently be used are: :ljust
or :left
, :rjust
or :right
, :commas
, :zpad
or :zeropad
, and :ipre
or :prefix
.
reset!{T}(::Type{T})
resets the defaults for a particular type.defaultSpec(x)
will return the defaults for the type of x, anddefaultSpec{T}(::Type{T})
will return the defaults for the given type.
There is currently support for Python style formatting, although that is a work-in-progress,
and I am intending to improve the syntax to make it as close as possible to Python's 3.6 format strings.
Currently, the syntax is \{<formatstring>}(expression)
, however I plan on changing it shortly to \{expression}
(equivalent to pyfmt("", expression)
, and \{expression;formatstring}
(equivalent to pyfmt("formatstring", expression)
.