friendlysam.models.MyopicDispatchModel.parts¶
-
MyopicDispatchModel.
parts
(depth='inf', include_self=True)¶ Get contained parts, recursively.
See also properties
children
,children_and_self
,descendants
,descendants_and_self
.Parameters: - depth (integer or ‘inf’, optional) – The recursion depth to search with. depth=1 searches among the parts directly contained by this part. depth=2 among children and their children, etc.
- include_self (boolean, optional) – Include this part in the results?
Returns: A set of parts.
Examples
>>> child = Part(name='Baby') >>> parent = Part(name='Mommy') >>> parent.add_part(child) >>> grandparent = Part('Granny') >>> grandparent.add_part(parent) >>> grandparent.children == {parent} True >>> grandparent.descendants == {parent, child} True >>> grandparent.descendants_and_self == {grandparent, parent, child} True >>> grandparent.parts(depth=1, include_self=False) == grandparent.children True