[New-bugs-announce] [issue13173] Default values for string.Template

Bfontaine report at bugs.python.org
Thu Oct 13 23:16:05 CEST 2011

New submission from Bfontaine <batifon at yahoo.fr>:

This patch allows you to define default values for a string.Template, which is useful when you need to use a lot some values, but sometimes other values.

for example:

>>> from string import Template
>>> s = Template("${user} made me a ${flavor} cake.", default={"user":"Dennis"})
>>> s.substitute(flavor="vanilla")
'Dennis made me a vanilla cake.'
>>> s.substitute(user="Ken", flavor="chocolate")
'Ken made me chocolate cake.'

components: Library (Lib)
files: string_template_default_values.tar
messages: 145485
nosy: nitupho
priority: normal
severity: normal
status: open
title: Default values for string.Template
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file23398/string_template_default_values.tar

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list