[erlang-questions] Question re io:format and string handling
Fri Oct 17 16:26:49 CEST 2008
Consider the result of evaluating the following in an erl console:
io:format("The ~p in the ~p", ["cat", "hat"]).
The strings "cat" and "hat" are substituted for the occurrences of ~p, and a
string is printed to the console.
Is there a way to bind that string to a variable instead of printing it to
What I am after is a facility somewhat like the one used in the Python
phrase = "The %s in the %s" % ("cat", "hat")
Evaluating the example above results in the variable 'phrase' taking the
value "The cat in the hat".
The similarity to the io:format behavior is clear. The Python idiom is
useful, and I have been looking for something
similar in Erlang, without luck. Before I try to concoct such a thing, I
thought I'd ask whether it already exists.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions