Re: Keyed format specifier
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Keyed format specifier
- From: Thomas Harning <harningt@...>
- Date: 2008年1月03日 13:50:47 -0500
Erik von Reis wrote:
My apologies if this is the wrong place to suggest this, but how about
adding a keyed format specifier for string.format?
To me,
string.format("%(foo)s = %(bar)d", {foo = "variable", bar = 22})
which I stole from Python, would be very handy and fits comfortably
into the primitive way I think about Lua.
Erik von Reis
This would be pretty easily done w/:
string.gsub("%(foo)s = %(bar)d", "%%%(([^)]+)%)", {foo = "variable",
bar = 22})
you could abstract it a bit...