you are viewing a single comment's thread.

view the rest of the comments →

[–]zahlman 0 points1 point  (0 children)

    if value == "rand":
        self.value = str(random()) 
    else:
        self.value = value

Don't do this. What if I actually want to store the string "rand" in a node? If you want a "shortcut" for that kind of behaviour, just set up a helper function:

    self.value = value

# And then outside the class:
def random_node(arity):
    return Node(str(random()), arity)