Classes

The class statement

     class Account:
         def __init__(self, initial):
             self.balance = initial
         def deposit(self, amt):
             self.balance = self.balance + amt
         def withdraw(self,amt):
             self.balance = self.balance - amt
         def getbalance(self):
             return self.balance 

Using a class

     a = Account(1000.00)
     a.deposit(550.23)
     a.deposit(100)
     a.withdraw(50)
     print a.getbalance() 
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 16
July 17, 2000, beazley@cs.uchicago.edu
>>>