[Tutor] OOP explanation article

Michael Miller blackmariah@shmups.com
Thu Jan 16 19:42:07 2003


> So in your article you say you can call Basket.add(ITEM) to add
> an item to your basket. This is not correct, as you also need to specify
> which basket you want to add the item to.

I was aware of that, but decided it might be clearer if I omitted that fact. 
After having it pointed out, it does seem kind of silly not to have it in the 
article. I'll fix that later.


> The same concepts described in your article can be explained using:
>
> class Basket:
>          def __init__(self,name):
>                     self.name = name
>                     self.contents = []
>
>          def add(self, newItem):
>                     self.contents = self.contents + [newItem]
>
>          def describe (self):
>                    print self.name, "contains", self.contents
>

Thanks a lot for that. I grabbed that code from Magnus lie Hetland's Python 
tutorial with the intention of replacing it with something else eventually. 
Would you mind if I used your simplified code instead?

Michael