Chocolate [was Re: Python Books for 2002]

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Apr 11 21:58:11 EDT 2001


Ben Wolfson wrote:
> 
> from Animals.Mammals import Human
> 
> hungry_person = Human()
> 
> So that the hungry_person can .consume() the comestibles.

But the method of consumption depends on the class
of the substance, so dispatching on it seems
appropriate. Perhaps

  substance.be_consumed_by(person)

Then in the future one could define additional
classes of substance such as Cocaine and Heroin
and the code will continue to work.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list