Это мой код (извините за дамп кода):
Код: Выделить всё
class Account:
"""simple account balance of bank"""
def __init__ (self, name, balance):
self.name = name
self.balance = balance
print('Account of ' + self.name)
def deposit(self, amount):
if amount > 0:
self.balance += amount
self.statement()
def withdrawal(self, amount):
if amount > 0 and self.balance > amount:
self.balance -= amount
self.statement()
else:
print("the ammount in your is not sufficent")
self.statement()
def statement(self):
print("Hi {} your current balance is {}".format(self.name,self.balance))
def transfer(self, amount, name):
self.balance = self.balance - amount
name.balance = name.balance + amount
return name.balance()
Код: Выделить всё
abc = Account("abc", 0)
abc.deposit(1000)
siddharth = Account("siddharth", 159)
Код: Выделить всё
siddharth.transfer(11, "abc")
siddharth.transfer(11, Account.abc)
Подробнее здесь: https://stackoverflow.com/questions/517 ... -in-python
Мобильная версия