File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,25 @@ reassigned.
5959 >>> template = t" Hello {name} !"
6060 >>> type (template)
6161 <class 'string.templatelib.Template'>
62+
63+ Templates ars stored as sequences of literal :attr: `~Template.strings `
64+ and dynamic :attr: `~Template.interpolations `.
65+ A :attr: `~Template.values ` attribute holds the interpolation values:
66+
6267 >>> template.strings
6368 ('Hello ', '!')
69+ >>> template.interpolations
70+ (Interpolation('World', ...),)
6471 >>> template.values
6572 ('World',)
6673
74+ The :attr: `!strings ` tuple has one more element than :attr: `!interpolations `
75+ and :attr: `!values `; the interpolations “belong” between the strings.
76+ This may be easier to understand when tuples are aligned::
77+
78+ template.strings: ('Hello ', '!')
79+ template.values: ( 'World', )
80+
6781 While literal syntax is the most common way to create :class: `!Template `
6882 instances, it is also possible to create them directly using the constructor:
6983
You can’t perform that action at this time.
0 commit comments