[Python-ideas] A tree data structure for Python
Grant Jenks
grant.jenks at gmail.com
Wed Feb 17 13:57:22 EST 2016
On Wed, Feb 17, 2016 at 9:01 AM, Stephan Foley <foley12723 at gmail.com> wrote:
> Hello, I would love to see a tree data structure out of the box for
> python. I'm thinking of a n-ary or multiway tree.
Reminds me of the "one-line tree in Python" hack:
https://gist.github.com/hrldcpr/2012250 Here's the gist of it:
from collections import defaultdict
def tree():
return defaultdict(tree)
It's almost too flexible but writing methods to traverse is relatively easy.
Grant
More information about the Python-ideas
mailing list