[Python-Dev] Multiple dicts for string interpolation?
Jim Fulton
jim@digicool.com
Fri, 28 Jan 2000 10:10:26 -0500
Tim Peters wrote:
>
(snip)
> I wasn't aware of the MultiDict approach Skip mentioned,
See the MultiMapping module in ExtensionClass. You can get the
latest flavor of this in the latest Zope release.
> but thought it
> looked spot on for the general case! Skip, is the long-windedness of
>
> dict = MultiDict()
> dict.append(d1)
> dict.append(d2)
> ...
> s = format % dict
Note the rather important *stack* sematics of
MultiMappings. We often push and pop namespaces
on and off of MultiMappings in use.
> the part you didn't like about that? If so, how about changing the
> constructor to
>
> def __init__(self, *dicts):
> ...
>
> instead so you could use it as a one-liner
>
> format % MultiDict(d1, d2, ...)
>
> ? That's exactly the same as the tuple idea, except there's a nice
> descriptive word in the middle of it <wink>.
This is exactly what the current MultiMapping "class" does.
Jim
--
Jim Fulton mailto:jim@digicool.com Python Powered!
Technical Director (888) 344-4332 http://www.python.org
Digital Creations http://www.digicool.com http://www.zope.org
Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission. Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.