def listAccounts(filter): if filter == "active": accounts = Account.list("active") elif filter == "deleted": accounts = Account.list("deleted") elif filter == "debts": accounts = Account.list("debts") elif filter == "staff": accounts = Account.list("staff") else: raise ApiError("Wrong filter, must be one of these: active, deleted, debts, staff") for account in accounts: account.balance = str(account.balance) return [acc.serialize() for acc in accounts]