kuber
07-10-2002, 01:04 PM
Ok, say I have 2 classes, one is defined as such:
class book:
def __init__(self, au, na):
self.author = ar
self.name = na
def displayauthor(self):
print self.author
def displayname(self):
print self.name
Now I want to define a class that will be a collection of book objects, but I am not sure how to do this, something like this is all I came up with (incomplete):
(obviously this would only add book w/ key 1)
class collection
def addbook(self, bo):
self.bo[1] = bo.displayname()
This isn't right obviously.. I was wondering how I would do this.. ?
class book:
def __init__(self, au, na):
self.author = ar
self.name = na
def displayauthor(self):
print self.author
def displayname(self):
print self.name
Now I want to define a class that will be a collection of book objects, but I am not sure how to do this, something like this is all I came up with (incomplete):
(obviously this would only add book w/ key 1)
class collection
def addbook(self, bo):
self.bo[1] = bo.displayname()
This isn't right obviously.. I was wondering how I would do this.. ?