[Python-Dev] PEP_215_ (string interpolation) alternative EvalDict

Neil Schemenauer nas@python.ca
2002年1月14日 17:54:53 -0800


Jason Orendorff wrote:
> The substitution only happens once.

My example was not well thought out. I was thinking something more
like:
 secret_key = "spam"
 user = "joe"
 x = "$user said: " + raw_input()
 print $x
That wouldn't work either since $ only evaluates literals. Amazing what
you learn by actually reading the PEP. Yes, I'm an idiot.
After reading PEP 215 I like it a lot. The fact that $ can only apply
to literals completely solves this issue. Has Guido weighed in on it
yet? I didn't find anything in the mail archives from him.
 Neil

AltStyle によって変換されたページ (->オリジナル) /