class Xiaorui:
def __init__(self):
self.name = 'xiaorui'
def setName(self, name=''):
if name.strip():
self.name = name
def getName(self):
return self.name
def greet(self):
print("Hello, i'm %s" % self.name)
foo = Xiaorui()
if(hasattr(foo, 'setName')):
print(foo.setName())
if(hasattr(foo, 'getName')):
print(foo.getName())
if(hasattr(foo, 'setName')):
print(foo.setName('wcf'))
if(hasattr(foo, 'getName')):
print(foo.getName())