String formatting with two dictionaries?
Chris Liechti
cliechti at gmx.net
Mon Oct 8 13:54:39 EDT 2001
More information about the Python-list mailing list
Mon Oct 8 13:54:39 EDT 2001
- Previous message (by thread): String formatting with two dictionaries?
- Next message (by thread): String formatting with two dictionaries?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Carsten Gaebler <clpy at snakefarm.org> wrote in news:3BC166F4.5E7FAB08 at snakefarm.org: > Given a string > s = "%(foo)s %(spam)s" > and two dictionaries > d1 = {"foo": "bar"} > d2 = {"spam": "eggs"} > > how would you apply d1 and d2 to s without modifying or explicitly > copying one of the dicts? > s = ("%(foo)s %%(spam)s" % d1) % d2 use two "%" for variables that are in the second dict. Chris -- Chris <cliechti at gmx.net>
- Previous message (by thread): String formatting with two dictionaries?
- Next message (by thread): String formatting with two dictionaries?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list