modernize some Python code

Since we now require Python 3.6, we can use f-strings instead of
format() to make the code more readable.

* doc/org/tut01.org, doc/org/tut02.org, doc/org/tut03.org,
doc/org/tut21.org, doc/org/tut24.org, doc/org/tut90.org,
python/spot/__init__.py, python/spot/jupyter.py, tests/python/acc.py,
tests/python/acc_cond.ipynb, tests/python/complement_semidet.py,
tests/python/decompose.ipynb, tests/python/formulas.ipynb,
tests/python/highlighting.ipynb, tests/python/ipnbdoctest.py,
tests/python/ltlf.py, tests/python/parity.ipynb,
tests/python/product.ipynb, tests/python/relabel.py,
tests/python/satmin.ipynb, tests/python/stutter-inv.ipynb,
tests/python/twagraph-internals.ipynb, tests/python/zlktree.ipynb: Use
f-strings.
This commit is contained in:
Alexandre Duret-Lutz 2024-03-26 20:35:10 +01:00
parent df44f7a5c2
commit 7ac570fa3f
23 changed files with 292 additions and 327 deletions

View file

@ -252,7 +252,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"execution_count": 3,
@ -784,7 +784,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -1043,7 +1043,8 @@
],
"source": [
"for ed in aut.out(0):\n",
" print(\"edges[{e}].src={src}, edges[{e}].dst={dst}\".format(e=aut.edge_number(ed), src=ed.src, dst=ed.dst))"
" en = aut.edge_number(ed)\n",
" print(f\"edges[{en}].src={ed.src}, edges[{en}].dst={ed.dst}\")"
]
},
{
@ -1293,7 +1294,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -1759,7 +1760,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -1979,7 +1980,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the `succ_tail` field of the `states` vector is seldom used when reading automata as the linked list of edges ends when `next_succ` (or `succ`) equals `0`. Its main use is during calls to `new_edge()`: new edges are always created at the end of the list (otherwise it would be hard to preserve the order of edges when parsing and automaton and printing it)."
"Note that the `succ_tail` field of the `states` vector is seldom used when reading automata as the linked list of edges ends when `next_succ` (or `succ`) equals `0`. Its main use is during calls to `new_edge()`: new edges are always created at the end of the list (otherwise it would be hard to preserve the order of edges when parsing an automaton and printing it)."
]
},
{
@ -2233,7 +2234,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -2604,7 +2605,7 @@
"while it:\n",
" e = it.current()\n",
" toerase = e.acc.has(1)\n",
" print(\"pos={}, acc={}, toerase={}\".format(aut.edge_number(e), e.acc, toerase))\n",
" print(f\"pos={aut.edge_number(e)}, acc={e.acc}, toerase={toerase}\")\n",
" if toerase:\n",
" it.erase()\n",
" else:\n",
@ -2900,7 +2901,8 @@
],
"source": [
"for e in aut.edges(): # iterate over all non-erased edges\n",
" print(\"edges[{e}].src={src}, edges[{e}].dst={dst}\".format(e=aut.edge_number(e), src=e.src, dst=e.dst))"
" en = aut.edge_number(e)\n",
" print(f\"edges[{en}].src={e.src}, edges[{en}].dst={e.dst}\")"
]
},
{
@ -3398,7 +3400,8 @@
],
"source": [
"for e in aut.edges(): # iterate over all non-erased edges\n",
" print(\"edges[{e}].src={src}, edges[{e}].dst={dst}\".format(e=aut.edge_number(e), src=e.src, dst=e.dst))"
" en = aut.edge_number(e)\n",
" print(f\"edges[{en}].src={e.src}, edges[{en}].dst={e.dst}\")"
]
},
{
@ -3954,7 +3957,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"execution_count": 22,
@ -4768,7 +4771,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"execution_count": 28,
@ -5552,7 +5555,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -6260,7 +6263,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b477e340> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdcf63db0> >"
]
},
"metadata": {},
@ -6758,7 +6761,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b4794630> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdd05b7e0> >"
]
},
"metadata": {},
@ -7129,7 +7132,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fd9b4794630> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f1fdd05b7e0> >"
]
},
"metadata": {},
@ -7345,7 +7348,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.8"
}
},
"nbformat": 4,