[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: confused by the wierd "q" option of "string.format".
- From: Dirk Laurie <dpl@...>
- Date: Sat, 9 Jul 2011 17:15:05 +0200
On Sat, Jul 09, 2011 at 11:26:56AM +0200, Michal Kottman wrote:
>
> Don't expect any hand-holding from Lua. Quoting PIL: Lua gives you the
> power; you build the mechanisms. If you want a function to output a
> "nice" string for the users, write it yourself. In addition, the
> resulting code will be more readable, because IMO the following code:
>
> print(quote(str))
>
> is easier to understand than:
>
> print(string.format("%q", str))
>
Having written `quote`, you could even do this:
getmetatable('').__unm=quote
print(-str)
Dirk