Re: another question about classes and subclassing

2010-05-19 Thread cjw
On 18-May-10 17:51 PM, Alex Hall wrote: Hi again all, More about classes. I am still looking into my battleship game, and I will have several different craft. All craft have common attribs (position, alive, and so on) but each craft may be a surface ship, submarine, or airplane. All three are cra

Re: another question about classes and subclassing

2010-05-19 Thread Gregory Ewing
Dave Angel wrote: Inside the __init__() method of Submarine, simply call the __init__() method of Craft, with appropriate parameters. To elaborate on that a little, it looks like this: class Craft: def __init__(self, position): self.position = position class Submarine(Craft):

Re: another question about classes and subclassing

2010-05-19 Thread Gregory Ewing
Alex Hall wrote: So by calling submarine(craft) I am bringing in all of craft's attribs (subclassing)? Or does calling craft's __init__ method do that instead? By making Submarine a subclass of Craft, you are inheriting any methods, or other class attributes, defined in the classes themselves.

Re: another question about classes and subclassing

2010-05-19 Thread Gregory Ewing
Alex Hall wrote: Sorry, top-posting is a habit on some other lists I am on, and sometimes it follows me to lists where in-line posting is the way to do it. Which list you're on shouldn't matter. You should cultivate the habit of always quoting selectively and minimally, on any list. It may tak

Re: another question about classes and subclassing

2010-05-18 Thread Alex Hall
On 5/18/10, Dave Angel wrote: > Alex Hall wrote: >> Okay, that makes sense. So by calling submarine(craft) I am bringing >> in all of craft's attribs (subclassing)? Or does calling craft's >> __init__ method do that instead? Is there an advantage to doing it >> this way, rather than just making se

Re: another question about classes and subclassing

2010-05-18 Thread Dave Angel
Alex Hall wrote: Okay, that makes sense. So by calling submarine(craft) I am bringing in all of craft's attribs (subclassing)? Or does calling craft's __init__ method do that instead? Is there an advantage to doing it this way, rather than just making separate classes for everything, except for m

Re: another question about classes and subclassing

2010-05-18 Thread Alex Hall
Okay, that makes sense. So by calling submarine(craft) I am bringing in all of craft's attribs (subclassing)? Or does calling craft's __init__ method do that instead? Is there an advantage to doing it this way, rather than just making separate classes for everything, except for my own sense of orga

Re: another question about classes and subclassing

2010-05-18 Thread Dave Angel
Alex Hall wrote: Hi again all, More about classes. I am still looking into my battleship game, and I will have several different craft. All craft have common attribs (position, alive, and so on) but each craft may be a surface ship, submarine, or airplane. All three are craft, but a submarine can

another question about classes and subclassing

2010-05-18 Thread Alex Hall
Hi again all, More about classes. I am still looking into my battleship game, and I will have several different craft. All craft have common attribs (position, alive, and so on) but each craft may be a surface ship, submarine, or airplane. All three are craft, but a submarine can be submerged or no