[formatter] change 'L'/length conversion to 'n'

This commit is contained in:
Mike Fährmann
2025-06-22 13:40:13 +02:00
parent 9c9eb7a3bb
commit 5e0cdac337
3 changed files with 6 additions and 6 deletions

View File

@@ -117,9 +117,9 @@ Conversion specifiers allow to *convert* the value to a different form or type.
<td><code>["sun", "tree", "water"]</code></td>
</tr>
<tr>
<td align="center"><code>L</code></td>
<td align="center"><code>n</code></td>
<td>Return the <a href="https://docs.python.org/3/library/functions.html#len" rel="nofollow">length</a> of a value</td>
<td><code>{foo!L}</code></td>
<td><code>{foo!n}</code></td>
<td><code>7</code></td>
</tr>
<tr>

View File

@@ -484,7 +484,7 @@ _CONVERSIONS = {
"C": string.capwords,
"j": util.json_dumps,
"t": str.strip,
"L": len,
"n": len,
"T": util.datetime_to_timestamp_string,
"d": text.parse_timestamp,
"D": util.to_datetime,

View File

@@ -73,9 +73,9 @@ class TestFormatter(unittest.TestCase):
self._run_test("{l!j}", '["a","b","c"]')
self._run_test("{dt!j}", '"2010-01-01 00:00:00"')
self._run_test("{a!g}", "hello-world")
self._run_test("{a!L}", 11)
self._run_test("{l!L}", 3)
self._run_test("{d!L}", 3)
self._run_test("{a!n}", 11)
self._run_test("{l!n}", 3)
self._run_test("{d!n}", 3)
self._run_test("{i_str!i}", 12345)
self._run_test("{i_str!f}", 12345.0)
self._run_test("{f_str!f}", 12.45)