python 组合样例
class Bill():
def __init__(self, description):
self.description = description
class Tail():
def __init__(self, length):
self.length = length
class Duck():
def __init__(self, bill, tail):
self.bill = bill
self.tail = tail
def about(self):
print('This duck has a',self.bill.description,'and',self.tail.length)
bill = Bill('wide orage bill')
tail = Tail('long tail')
duck = Duck(bill,tail)
duck.about()
This duck has a wide orage bill and long tail