[issue13173] Default values for string.Template

2016-05-06 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python

[issue13173] Default values for string.Template

2013-11-10 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: I'm looking at this issue again with an eye toward Python 3.4. Raymond describes what I think is a reasonable way to use defaults: >>> x = Template('$foo $bar') >>> defaults = dict(foo='one', bar='two') >>> x.substitute(defaults) 'one two' >>> x.substitute(def

[issue13173] Default values for string.Template

2013-01-07 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- versions: +Python 3.4 -Python 3.3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue13173] Default values for string.Template

2012-06-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If the Template defaults should be attached directly to the template instance, then they should be attached directly to the string instance, for classic and modern string formatting. And this obviously is absurd. I agree with Éric, to mention ChainMap class

[issue13173] Default values for string.Template

2012-06-24 Thread Éric Araujo
Éric Araujo added the comment: It looks like a doc update to mention the excellent ChainMap class would be a good thing. Bfontaine, are you happy with using a Template subclass or changing your code slightly to have defaults outside of the Template objects, or do you still think the class sh

[issue13173] Default values for string.Template

2011-11-07 Thread Barry A. Warsaw
Barry A. Warsaw added the comment: When I need defaults, I make them part of the mapping that gets passed into .substitute() and .safe_substitute(). It doesn't feel to me like it's necessary to attach them to the Template instance. Also, couldn't you just subclass string.Template if you wan

[issue13173] Default values for string.Template

2011-10-29 Thread Raymond Hettinger
Raymond Hettinger added the comment: Barry, any thoughts? -- assignee: rhettinger -> barry nosy: +barry ___ Python tracker ___ ___ Py

[issue13173] Default values for string.Template

2011-10-19 Thread Bfontaine
Bfontaine added the comment: When you are using a lot of string templates like I am doing, I think it's better if the defaults is attached directly to the template instance. This: [, , , , ...] is easier to use than: [(, ), (, 1), ...] -- ___ Pytho

[issue13173] Default values for string.Template

2011-10-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: This looks like a reasonable use case. That being said, I question whether the defaults should be attached directly to the template instance or whether they should be part of the substitution method. FWIW, there already have a couple of other ways to do i

[issue13173] Default values for string.Template

2011-10-18 Thread Bfontaine
Bfontaine added the comment: A "light" version of diff added (rewrapped content is replaced by "[rewrapping]") -- Added file: http://bugs.python.org/file23455/string_template_default_values2-light.patch ___ Python tracker

[issue13173] Default values for string.Template

2011-10-18 Thread Bfontaine
Bfontaine added the comment: diff updated -- Added file: http://bugs.python.org/file23454/string_template_default_values2.patch ___ Python tracker ___ _

[issue13173] Default values for string.Template

2011-10-17 Thread Éric Araujo
Éric Araujo added the comment: Adding Georg, maintainer of the string module, to the nosy list. If he approves the idea, you can go ahead and complete your patch. -- nosy: +georg.brandl ___ Python tracker __

[issue13173] Default values for string.Template

2011-10-17 Thread Éric Araujo
Éric Araujo added the comment: Thanks for the patch. It mostly looks good; a detailed review follow. + The constructor takes two arguments, the first is the template string and + the second (optional) is a dictionary object which specify which values + should be used as default values,

[issue13173] Default values for string.Template

2011-10-14 Thread Bfontaine
Bfontaine added the comment: Here is my code as a diff -- keywords: +patch Added file: http://bugs.python.org/file23408/string_template_default_values.patch ___ Python tracker

[issue13173] Default values for string.Template

2011-10-14 Thread Éric Araujo
Éric Araujo added the comment: Thanks for your interest in Python. Can you repost your code as a diff? (See the devguide for more info) -- nosy: +eric.araujo versions: +Python 3.3 -Python 3.2 ___ Python tracker

[issue13173] Default values for string.Template

2011-10-13 Thread Bfontaine
New submission from Bfontaine : 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={