> Too many misconceptions here (I changed to a more PEP-8 style naming): > > class Gun(object): > def __init__(self): > self.shells = 10 > > class Battleship(object): > def __init__(self): > self.guns = [Gun(), Gun()] > > def getShellsLeft(self): > numShells = 0 > for aGun in self.guns: > numShells += aGun.shells > return numShells > > theBizmark = Battleship() > print theBizmark.getShellsLeft()
Excellent example - once upon a time I used to write very neat code indeed, but exposure to C# had pretty much knackered that (where all the framework object methods are capitalized). -- http://mail.python.org/mailman/listinfo/python-list