[Python-Dev] PEP 292, Simpler String Substitutions
Barry A. Warsaw
barry@zope.com
Wed, 19 Jun 2002 08:16:17 -0400
>>>>> "MS" =3D=3D Martin Sj=F6gren <martin@strakt.com> writes:
MS> What's the advantage of using ${name} and ${country} instead?
There's a lot of empirical evidence that %(name)s is quite error
prone.
BTW, you can't use locals() or globals() because you really want
globals()-overridden-with-locals(), i.e.
d =3D globals().copy()
d.update(locals())
vars() doesn't cut it either:
>>> help(vars)
Help on built-in function vars:
vars(...)
vars([object]) -> dictionary
=20
Without arguments, equivalent to locals().
With an argument, equivalent to object.__dict__.
-Barry