|
11 | 11 |
|
12 | 12 | .. seealso:: |
13 | 13 |
|
14 | | - :ref:`f-strings` -- Format strings (f-strings) |
| 14 | + :ref:`Format strings <f-strings>` |
15 | 15 |
|
16 | 16 |
|
17 | 17 | .. _templatelib-template: |
@@ -124,7 +124,6 @@ It is also possible to create a :class:`!Template` directly, using its construct |
124 | 124 | :type value: Literal["a", "r", "s"] | None |
125 | 125 |
|
126 | 126 | :param format_spec: An optional, arbitrary string used as the :ref:`format specification <formatspec>` to present the value. |
127 | | - :type expression: str = "" |
128 | 127 |
|
129 | 128 | The :class:`!Interpolation` type represents an expression inside a template string. It is shallow immutable -- its attributes cannot be reassigned. |
130 | 129 |
|
@@ -154,3 +153,32 @@ It is also possible to create a :class:`!Template` directly, using its construct |
154 | 153 |
|
155 | 154 | :returns: A tuple of the attributes to use for structural pattern matching. |
156 | 155 | :rtype: (Literal["value"], Literal["expression"], Literal["conversion"], Literal["format_spec"]) |
| 156 | + |
| 157 | + |
| 158 | + .. property:: value |
| 159 | + |
| 160 | + :returns: The evaluated value of the interpolation. |
| 161 | + :rtype: object |
| 162 | + |
| 163 | + .. property:: expression |
| 164 | + |
| 165 | + :returns: The original text of the interpolation's Python expression if the interpolation was created from a t-string literal |
| 166 | + :rtype: str |
| 167 | + |
| 168 | + The :attr:`~Interpolation.expression` is the original text of the interpolation's Python expression, if the interpolation was created from a t-string literal. Developers creating |
| 169 | + interpolations manually should either set this to an empty |
| 170 | + string or choose a suitable valid python expression. |
| 171 | + |
| 172 | + .. property:: conversion |
| 173 | + |
| 174 | + :returns: The conversion to apply to the value, one of "a", "r", or "s", or None. |
| 175 | + :rtype: Literal["a", "r", "s"] | None |
| 176 | + |
| 177 | + The :attr:`~Interpolation.conversion` is the optional conversion to apply to the value. This is one of "a", "r", or "s", or None if no conversion is specified. |
| 178 | + |
| 179 | + .. property:: format_spec |
| 180 | + |
| 181 | + :returns: The format specification to apply to the value. |
| 182 | + :rtype: str |
| 183 | + |
| 184 | + The :attr:`~Interpolation.format_spec` is an optional, arbitrary string used as the format specification to present the value. This is similar to the format specification used in :ref:`format strings <formatstrings>`, but it is not limited to a specific set of formats. |
0 commit comments