Marking translatable strings
Fredrik Lundh
fredrik at pythonware.com
Wed Sep 22 02:53:10 EDT 1999
Darrell <news at dorb.com> wrote:
> Wish there was a dictionary formatter that wouldn't throw a keyError when it
> was missing a value.
here's one:
import UserDict
class MessageTable(UserDict.UserDict):
def __getitem__(self, key):
return self.data.get(key, key)
messages = MessageTable({
"spam": "Spam",
"egg": "Egg"
})
print "%(spam)s %(egg)s %(bacon)s" % messages
</F>
More information about the Python-list
mailing list