on http://wiki.python.org/moin/SimplePrograms I found this code:

=======================================
class BankAccount(object):
    def __init__(self, initial_balance=0):
        self.balance = initial_balance
    def deposit(self, amount):
        self.balance += amount
    def withdraw(self, amount):
        self.balance -= amount
    def overdrawn(self):
        return self.balance < 0
my_account = BankAccount(15)
my_account.withdraw(5)
print my_account.balance
=========================================

This prints the expected "10".

My question is, of what use can "overdrawn" be put? If I change the withdrawal amount to 25, it prints the expected "-10", whether the class contains the "overdrawn" function or not.

Thanks,

Dick Moores
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to