treelib icon indicating copy to clipboard operation
treelib copied to clipboard

Implement public methods using private methods

Open 111pontes opened this issue 4 years ago • 0 comments

Overriding some of the current methods can have the nasty side effect of breaking other methods. Let me know if you'd consider having private version of methods used to implement other public methods. Something along the lines of:

def _is_leaf():  ## as currently implemented
    ...

def is_leaf():  ##  children can override without breaking leaves()
    return _is_leaf()

def leaves(self, nid=None):
    ...
            if node._is_leaf(self._identifier):
    ...

This change would be a great enhancement to make the tree more customizable and less likely to breakage. Not a theoretical exercise. Users are actually running into this type of situation. Happy to contribute 😎

111pontes avatar May 07 '20 01:05 111pontes