[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 ___

[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(defaults,

[issue13173] Default values for string.Template

2013-01-07 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- versions: +Python 3.4 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13173 ___ ___

[issue13173] Default values for string.Template

2012-06-25 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com 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

[issue13173] Default values for string.Template

2012-06-24 Thread Éric Araujo
Éric Araujo mer...@netwok.org 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

[issue13173] Default values for string.Template

2011-11-07 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org 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

[issue13173] Default values for string.Template

2011-10-29 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: Barry, any thoughts? -- assignee: rhettinger - barry nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13173 ___

[issue13173] Default values for string.Template

2011-10-19 Thread Bfontaine
Bfontaine bati...@yahoo.fr 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: [Template0, Template1, Template2, Template3, ...] is easier to use than: [(Template0, defaults0),

[issue13173] Default values for string.Template

2011-10-18 Thread Bfontaine
Bfontaine bati...@yahoo.fr added the comment: diff updated -- Added file: http://bugs.python.org/file23454/string_template_default_values2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13173

[issue13173] Default values for string.Template

2011-10-18 Thread Bfontaine
Bfontaine bati...@yahoo.fr 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 Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com 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

[issue13173] Default values for string.Template

2011-10-17 Thread Éric Araujo
Éric Araujo mer...@netwok.org 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

[issue13173] Default values for string.Template

2011-10-17 Thread Éric Araujo
Éric Araujo mer...@netwok.org 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 rep...@bugs.python.org

[issue13173] Default values for string.Template

2011-10-14 Thread Éric Araujo
Éric Araujo mer...@netwok.org 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-14 Thread Bfontaine
Bfontaine bati...@yahoo.fr 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 rep...@bugs.python.org http://bugs.python.org/issue13173

[issue13173] Default values for string.Template

2011-10-13 Thread Bfontaine
New submission from Bfontaine bati...@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.,