# -*- coding: utf-8 -*-
"""
Created on Mon Jul 11 21:37:46 2016
@author: yx
"""
class Node:
def __init__(self,node_name,**attr):
self.node_name=node_name
self.attr=attr
def display_name(self):
print self.node_name
def get_node_name(self):
return node_name
def set_node_name(self,new_node_name):
self.node_name=new_node_name
def get_attribute(self):
return self.attr
def get_attribute_with_attr_name(self,attr_name):
return attr[attr_name]
def add_attribute(self,attr_name,attribute):
attr[attr_name]=attribute
attr={}
node=Node("A",yuexiang="sb")
node.add_attribute("length","10m")
node.add_attribute("width","1dm")
node.display_name()
print node.get_attribute_with_attr_name("length")