0

I am working with a big sized tree in python, I am parsing a file that has some data and with every new line, many nodes are to be created if some conditions are satisfied.

I am wondering what would be a good way to name the nodes created automatically. I am using :

from anytree import Node, RenderTree

I have now in my nodes creation line of code:

(i,k)=("(i,k)",parent=(i-1,j))

where i is the depth of the tree, j is what node at that depth I am creating children for, and then I am creating the Kth child for that node.

I think working with dictionaries would work but I just want to first know if using the tuples is wrong.

basel117
  • 189
  • 1
  • 10
  • 1
    That code can't work, it's an assignment to a function call? – roganjosh Jun 29 '19 at 21:34
  • @roganjosh yes I mentionned that i doubted it might take the syntax in some other ways, any suggestions? – basel117 Jun 29 '19 at 21:37
  • Not liking the way something is written and it not being valid are two different things. You _could_ create a dictionary with that data as a tuple key but I'm not confident that this would be be the best approach – roganjosh Jun 29 '19 at 21:41
  • @roganjosh you're right, I modified the question and now it makes more sense, I am not sure about the dictionary approach either – basel117 Jun 29 '19 at 21:44

0 Answers0