caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
801 stars 185 forks source link

Additional support for subclassing of 'treelib.Node' #157

Open RichardHoekstra opened 4 years ago

RichardHoekstra commented 4 years ago

In my own project I am extensively subclassing both 'treelib.Tree' and 'treelib.Node'. Using the 'data' variable, as mentioned in the documentation under advanced usage, does not work well for my use case.

It would make my life easier, and my code prettier, if I can pass additional arguments to Tree.create_node. The dependency injection is already there (self.node_class) and this PR should unlock more of the potential. https://github.com/caesar0301/treelib/blob/017e891fcd5dc613004061cdc42e65cebea48ced/treelib/tree.py#L339-L346