Skip to content

Commit 4960068

Browse files
committed
Merge branch 'it-main'
2 parents f7817ab + cb85bca commit 4960068

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

slides.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,52 @@ template = t"<div>{name}</div>"
365365
```python314
366366
name = "world"
367367
template = t"<div>{name}</div>"
368+
list(template)
369+
# ["<div>", Interpolation(value="world"), "</div>"]
370+
```
371+
```python314
372+
name = "world"
373+
template = t"<div>{name}</div>"
374+
template.strings
375+
# ("<div>", "</div>")
376+
```
377+
```python314
378+
name = "world"
379+
template = t"<div>{name}</div>"
380+
template.interpolations
381+
# (Interpolation(value="world"),)
382+
```
383+
```python314
384+
name = "world"
385+
template = t"<div>{name}</div>"
386+
template.interpolations
387+
# (Interpolation(
388+
# value="world",
389+
# expression="name",
390+
# conversion=None,
391+
# format_spec="",
392+
# ))
393+
```
394+
```python314
395+
name = "world"
396+
template = t"<div>{name!s:>10}</div>"
397+
template.interpolations
398+
# (Interpolation(
399+
# value="world",
400+
# expression="name",
401+
# conversion="s",
402+
# format_spec=">10",
403+
# ))
404+
```
405+
```python314
406+
name = "world"
407+
template = t"<div>{name}</div>"
408+
list(template)
409+
# ["<div>", Interpolation("world"), "</div>"]
410+
```
411+
```python314
412+
name = "world"
413+
template = t"<div>{name}</div>"
368414
for item in template:
369415
...
370416
```
@@ -403,11 +449,7 @@ for item in template:
403449
if isinstance(item, str):
404450
print("static:", item)
405451
else:
406-
# `item` is a `string.templatelib.Interpolation`
407452
print("dynamic:", item.value)
408-
# static: <div>
409-
# dynamic: world
410-
# static: </div>
411453
```
412454
```python314
413455
name = "world"

0 commit comments

Comments
 (0)