skbio.tree.TreeNode.pop#

TreeNode.pop(index=-1, uncache=True)[source]#

Remove and return a child node by index position from self.

Parameters:
indexint, optional

The index position in children to pop.

uncachebool, optional

Whether to clear caches of the tree if present (default: True). See details.

Added in version 0.6.3.

Returns:
TreeNode

The popped child node.

Raises:
IndexError

If the index position does not exist.

Notes

The parent of the popped node will be set to None.

Examples

>>> from skbio import TreeNode
>>> tree = TreeNode.read(["(a,b)c;"])
>>> print(tree.pop(0))
a;