On this page
graphlib.CycleError
Up: graphlib | Next: graphlib.TopologicalSorter
Rel: graphlib.TopologicalSorter
Ref: docs.python.org โ graphlib.CycleError
Tags: #public #python3 #stdlib #graphlib
Import
import graphlib
from graphlib import CycleError
Signature & Overview
graphlib.CycleError(...)
Subclass of ValueError raised by TopologicalSorter.prepare if cycles exist in the working graph.
Methods & Attributes
CycleError.add_note(self, note, /)โ Add a note to the exceptionCycleError.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import graphlib
ts = graphlib.TopologicalSorter({"a": ["b"], "b": ["a"]})
try:
list(ts.static_order())
except graphlib.CycleError as exc:
assert len(exc.args[1]) >= 2 # cycle path nodes
Gotchas
- Inspect
exc.args[1]: Contains the exact list of nodes forming the dependency cycle.
REPL Inspect
from graphlib import CycleError
help(CycleError)
Linked from
Related notes
- tuts/python3/stdlib_module/graphlib/TopologicalSorter Linked here; links to this page; shared tags: #graphlib, #stdlib
- tuts/python3/stdlib_module/graphlib Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib
- tuts/c/stdlib/ctype/isspace shared tags: #stdlib