如何在 Python 中的树节点中添加列表?

How can I add a list in a Tree`s node in Python?

我正在尝试在我的 AVL 树的这个节点内创建一个列表,我也尝试了一个函数,有人有一些库要导入或有什么想法吗?

#import random, math
import re
outputdebug = False 

def debug(msg):
    if outputdebug:
    print msg

class Node():
    def __init__(self, key):
        self.key = key
        self.left = None 
        self.right = None 
        self.list = [] #list at the node

class AVLTree():
    def __init__(self, *args):
        self.node = None 
        self.height = -1  
        self.balance = 0; 

    def ad_list(self, value):
        self.list.append(value) #function trying to add

    def print_list(self):
        print self.list

您的 AVLTree class 没有列表,但是您的 Node class:

self.node.list.append(value) #function trying to add