from abc import ABCMeta, abstractmethod class Card: def __init__(self): print('proxy interface') @abstractmethod def consume(self, account): pass @abstractmethod def getAccount(self): pass # @abstractmethod def transferAccount(self): raise NotImplementedError class ATMProxy(Card): def __init__(self): self.bank = MingShengBank() def consume(self, account): self.account = self.getAccount if self.account < account: return('account is not enough') else: self.bank.consume(account) return(self.getAccount) @property def getAccount(self): return self.bank.getAccount() class MingShengBank(Card): account =10 def consume(self, account): self.account = self.account - account print('consume') def getAccount(self): return self.account if __name__=='__main__': p = ATMProxy() print(p.getAccount) print(p.consume(2)) print(p.consume(3))