View Problem

Define a string containing variables and expressions

Given variables a=3 and b=4 output "3+4=7"
DiskEdit
python
class EvalDict(dict):
def __getitem__(s, k):
return eval(k, s)

a=3; b=4
"%(a)d+%(b)d=%(a+b)d" % EvalDict(locals())
DiskEdit
python
a=3; b=4
"%d+%d=%d" % (a, b, a+b)

Submit a new solution for python
There are 28 other solutions in additional languages (clojure, cpp, csharp, erlang ...)