Logo

Programming-Idioms

History of Idiom 17 > diff from v47 to v48

Edit summary for version 48 by acnebs:
[Python] Inheriting from object is redundant in python3

Version 47

2020-04-29, 09:24:07

Version 48

2020-04-29, 09:40:38

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Code
class Node(object):
    def __init__(self, value, *children):
        self.value = value
        self.children = list(children)
Code
class Node:
    def __init__(self, value, *children):
        self.value = value
        self.children = list(children)