def account_check(f):
 def wrapper(self, *args, **kwargs):
  for arg in args:
   if (isinstance(arg, PaymentAccount) and (arg.provider != self.provider)):
    raise ValueError('Wrong account {0} != {1}'.format(arg.provider, self.provider))
  return f(self, *args, **kwargs)
 return wrapper

def account_check ( f ) : def wrapper ( self , * args , ** kwargs ) : for arg in args : if ( isinstance ( arg , PaymentAccount ) and ( arg . provider != self . provider ) ) : raise ValueError ( 'Wrong account {0} != {1}' . format ( arg . provider , self . provider ) ) return f ( self , * args , ** kwargs ) return wrapper
use this decorator on provider methods to ensure that the account being passed into the method belongs to that provider .