All,

I've a question about treelib library from pip.

Treelib stores a tree and offers functions to add, delete or move
nodes. Furthermore, you can print a tree like this:

Harry
├── Harry2
├── Harry3
├── Harry4
└── Jane
    ├── Jane2
    │   ├── Jane2.1
    │   │   └── Jane2.1.1
    │   ├── Jane2.2
    │   └── Jane2.3
    └── Jane3



I'm trying to understand how the print function is working.

1. The documentation [2] says, you have to call tree.show() to print
the tree above.
2. tree.show calls the self__print_backend(...)
3. It seems that nid is initialized in get_iter, Line 218 [1]
4. nid is passed as parameter to __get_iter and the other
participating funtions
5. the node with the id nid is fetched in line 222.
6. In Line 190 there's a loop.

I don't understand what increments nid or what makes the __get_iter
function loop through the self._nodes dictionary defined in Line 106?
Couldn't the __get_iter function iterate another list or dictionary?
Which line says that you want to get every Node in self._nodes?

Thank you in advance!

- Chris

[1] https://github.com/caesar0301/treelib/blob/master/treelib/tree.py
[2] http://treelib.readthedocs.io/en/latest/examples.html#basic-usage
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to