Skip to content

Commit ae9847e

Browse files
authored
Update README.md
1 parent a4c1ad2 commit ae9847e

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

README.md

+29-4
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,36 @@ This is especially useful when defaults have been set for the type of the first
4040
* `fmt_default!{T}(::Type{T}, syms::Symbol...; kwargs...)` sets the defaults for a particular type.
4141
* `fmt_default!(syms::Symbol...; kwargs...)` sets the defaults for all types.
4242

43-
Symbols that can currently be used are: `:ljust` or `:left`, `:rjust` or `:right`, `:commas`, `:zpad` or `:zeropad`, and `:ipre` or `:prefix`.
43+
Symbols that can currently be used are: `:ljust` or `:left`, `:rjust` or `:right`, `:center`, `:commas`, `:zpad` or `:zeropad`, and `:ipre` or `:prefix`.
44+
Several keyword arguments can also be used:
45+
Keyword | Type | Meaning | Default
46+
--------|------|---------------------------|-------
47+
fill | Char | Fill character | ' '
48+
align | Char | Alignment character | '\\0'
49+
sign | Char | Sign character | '-'
50+
width | Int | Field width | -1, i.e. ignored
51+
prec | Int | Floating Precision | -1, i.e. ignored
52+
ipre | Bool | Use 0b, 0o, or 0x prefix? | false
53+
zpad | Bool | Pad with 0s on left | false
54+
tsep | Bool | Use thousands separator? | false
55+
4456
* `reset!{T}(::Type{T})` resets the defaults for a particular type.
4557
* `defaultSpec(x)` will return the defaults for the type of x, and
4658
* `defaultSpec{T}(::Type{T})` will return the defaults for the given type.
4759

48-
There is currently support for Python style formatting, although that is a work-in-progress,
49-
and I am intending to improve the syntax to make it as close as possible to Python's 3.6 format strings.
50-
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)`.
60+
There is also support for Python style formatting, which supports most options (except for '%' currently).
61+
62+
# Python style formatting specification language
63+
64+
spec ::= [[fill]align][sign][#][0][width][,_][.prec][type]
65+
fill ::= <any character>
66+
align ::= '<' | '^' | '>'
67+
sign ::= '+' | '-' | ' '
68+
width ::= <integer>
69+
prec ::= <integer>
70+
type ::= 'b' | 'c' | 'd' | 'e' | 'E' | 'f' | 'F' | 'g' | 'G' | 'n' | 'o' | 'x' | 'X' | 's'
71+
72+
Please refer to http://docs.python.org/2/library/string.html#formatspec
73+
for more details
74+
75+
The syntax is slightly different, `\{<formatspec>}(expression)`, instead of `{variable:formatspec}`, so as to fit better with Julia's string syntax.

0 commit comments

Comments
 (0)