'''
Created on 2014-10-25
@author: XSD
'''
class User:
'''
example class <User>
'''
def __init__(self, params={}):
'''
初始化对象
'''
if type(params) != type({}):
raise TypeError("error type %s" % type(params))
self.items = params
return
def _get_info(self, id):
'''
获取信息
'''
if id not in self.items.keys():
raise KeyError("error key %s" % id)
return self.items[id]
def do_handler():
'''
invoke...
'''
u = User({'a':100, 'b':85, 'c':70})
return u._get_info('b')
if __name__ == "__main__":
print(do_handler())
Created on 2014-10-25
@author: XSD
'''
class User:
'''
example class <User>
'''
def __init__(self, params={}):
'''
初始化对象
'''
if type(params) != type({}):
raise TypeError("error type %s" % type(params))
self.items = params
return
def _get_info(self, id):
'''
获取信息
'''
if id not in self.items.keys():
raise KeyError("error key %s" % id)
return self.items[id]
def do_handler():
'''
invoke...
'''
u = User({'a':100, 'b':85, 'c':70})
return u._get_info('b')
if __name__ == "__main__":
print(do_handler())