This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年07月08日 00:36 by py.user, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg140010 - (view) | Author: py.user (py.user) * | Date: 2011年07月08日 00:36 | |
>>> import string
>>> class MyTemplate(string.Template):
... delimiter = '.'
...
>>> MyTemplate.delimiter = 'x'
>>> mt = MyTemplate('.field xfield')
>>> mt.substitute(field=None)
'None xfield'
>>> mt.delimiter
'x'
>>>
If I want to change the pattern string by any delimiter, I should create a new class for every delimiter
I would change the delimiter either in the object or in the class at any time
|
|||
| msg140038 - (view) | Author: SilentGhost (SilentGhost) * (Python triager) | Date: 2011年07月08日 18:16 | |
3.1 is in security fixes-only mode |
|||
| msg140047 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2011年07月09日 02:54 | |
You are correct that this is a feature request as written. I think there is also a doc bug (the docs should probably mention that changing delimiter after class creation is a no-op). To add this feature the computation of the regex would need to be moved from the metaclass init to the object init. The question is, was doing this in a metaclass a design decision (perhaps a micro-optimization?), or a "cute trick" that turns out to cause unintuitive consequences? I think Barry was involved in adding the Template feature, so I'm adding him as nosy (I don't have a clone handy to check hg annotate). |
|||
| msg140118 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年07月11日 13:05 | |
See 629200d880ea for answers. |
|||
| msg140123 - (view) | Author: Barry A. Warsaw (barry) * (Python committer) | Date: 2011年07月11日 13:13 | |
I don't know that anybody relies on the current behavior and computers are now a bazillion times faster than they were in 2004, so who needs that micro optimization any more? |
|||
| msg290673 - (view) | Author: Barry A. Warsaw (barry) * (Python committer) | Date: 2017年03月28日 00:44 | |
As this issue has been open for a long time, and I don't think it's worth changing the implementation, I am changing this to a documentation bug and will fix it along with the rewrites for bpo-19824 and bpo-20314 |
|||
| msg290718 - (view) | Author: Barry A. Warsaw (barry) * (Python committer) | Date: 2017年03月28日 14:02 | |
New changeset 9f74deba784fc8781d13ed564f69c02ed7c331bb by Barry Warsaw in branch 'master': Improve the documentation for template strings (#856) https://github.com/python/cpython/commit/9f74deba784fc8781d13ed564f69c02ed7c331bb |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56727 |
| 2017年03月28日 14:04:00 | barry | set | status: open -> closed resolution: fixed stage: resolved |
| 2017年03月28日 14:02:09 | barry | set | messages: + msg290718 |
| 2017年03月28日 00:44:19 | barry | set | assignee: barry messages: + msg290673 components: + Documentation, - Library (Lib) versions: + Python 3.7, - Python 3.3 |
| 2011年07月11日 13:13:51 | barry | set | messages: + msg140123 |
| 2011年07月11日 13:05:12 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg140118 |
| 2011年07月09日 02:54:58 | r.david.murray | set | nosy:
+ barry, r.david.murray messages: + msg140047 versions: + Python 3.3, - Python 3.2 |
| 2011年07月08日 18:16:58 | SilentGhost | set | nosy:
+ SilentGhost messages: + msg140038 versions: + Python 3.2, - Python 3.1 |
| 2011年07月08日 00:36:49 | py.user | create | |