Re: is this the right way to do subclasses?

2006-11-09 Thread John Salerno
Steve Holden wrote: >> Wait, I just might be an idiot. Is it not even necessary for me to >> call Character's __init__ method? Fighter will inherit it >> automatically and call it when a Fighter object is created, right? >> > By Jove, he's got it! But I was thinking...even though there are bett

Re: is this the right way to do subclasses?

2006-11-09 Thread John Salerno
Bruno Desthuilliers wrote: > John Salerno a écrit : >> Peter Otten wrote: >> >>> You may need a no-op implementation of fix_attributes() in the Character >>> class. >> >> >> What does that mean? Is that in case I use Character directly to >> create an object? > > Most propbably it can be useful f

Re: is this the right way to do subclasses?

2006-11-08 Thread Gabriel Genellina
At Wednesday 8/11/2006 22:35, Ben Finney wrote: class Character(object): stat_keys = ['strength', 'dexterity', 'intelligence'] def __init__(self, name, stats): self.name = name self.health = 10 self.stats = {} for (key, value) i

Re: is this the right way to do subclasses?

2006-11-08 Thread Ben Finney
John Salerno <[EMAIL PROTECTED]> writes: > Ok, back to my so-called "game." I'm just curious if I've > implemented the subclasses properly, because it seems like an awful > lot of repetition with the parameters. And again, if I want to add a > new attribute later, I'd have to change a lot of thing

Re: is this the right way to do subclasses?

2006-11-08 Thread Bruno Desthuilliers
John Salerno a écrit : > Peter Otten wrote: > >> You may need a no-op implementation of fix_attributes() in the Character >> class. > > > What does that mean? Is that in case I use Character directly to create > an object? Most propbably it can be useful for other character classes that don't

Re: is this the right way to do subclasses?

2006-11-08 Thread Bruno Desthuilliers
John Salerno a écrit : > Ok, back to my so-called "game." I'm just curious if I've implemented > the subclasses properly, because it seems like an awful lot of > repetition with the parameters. And again, if I want to add a new > attribute later, I'd have to change a lot of things. I can't help

Re: is this the right way to do subclasses?

2006-11-08 Thread Steve Holden
John Salerno wrote: > John Salerno wrote: >> Peter Otten wrote: >> >>> Try it: Fighter(...) will implicitly call Character.__init__(...). >> Ok, I'm confused! :) I thought you had to explicity call a base class's >> __init__ method? How is it doing this? > > Wait, I just might be an idiot. Is it

Re: is this the right way to do subclasses?

2006-11-08 Thread John Salerno
Peter Otten wrote: > You may need a no-op implementation of fix_attributes() in the Character > class. What does that mean? Is that in case I use Character directly to create an object? Would that just be a 'pass' statement? -- http://mail.python.org/mailman/listinfo/python-list

Re: is this the right way to do subclasses?

2006-11-08 Thread John Salerno
John Salerno wrote: > Peter Otten wrote: > >> Try it: Fighter(...) will implicitly call Character.__init__(...). > > Ok, I'm confused! :) I thought you had to explicity call a base class's > __init__ method? How is it doing this? Wait, I just might be an idiot. Is it not even necessary for me t

Re: is this the right way to do subclasses?

2006-11-08 Thread John Salerno
Peter Otten wrote: > Try it: Fighter(...) will implicitly call Character.__init__(...). Ok, I'm confused! :) I thought you had to explicity call a base class's __init__ method? How is it doing this? -- http://mail.python.org/mailman/listinfo/python-list

Re: is this the right way to do subclasses?

2006-11-08 Thread Gabriel G
At Wednesday 8/11/2006 16:33, John Salerno wrote: > class Character(object): > def __init__(self, name, strength, dexterity, intelligence): > self.name = name > self.health = 10 > self.strength = strength > self.dexterity = dexterity > self.intelligenc

Re: is this the right way to do subclasses?

2006-11-08 Thread Peter Otten
John Salerno wrote: > Peter Otten wrote: > >> One way to avoid the repetition: >> >> class Character(object): >> def __init__(self, name, strength, dexterity, intelligence): >> self.name = name >> self.health = 10 >> self.strength = strength >> self.dexterity

Re: is this the right way to do subclasses?

2006-11-08 Thread John Salerno
Peter Otten wrote: > One way to avoid the repetition: > > class Character(object): > def __init__(self, name, strength, dexterity, intelligence): > self.name = name > self.health = 10 > self.strength = strength > self.dexterity = dexterity > self.intell

Re: is this the right way to do subclasses?

2006-11-08 Thread Peter Otten
John Salerno wrote: > Ok, back to my so-called "game." I'm just curious if I've implemented > the subclasses properly, because it seems like an awful lot of > repetition with the parameters. And again, if I want to add a new > attribute later, I'd have to change a lot of things. I can't help but >

Re: is this the right way to do subclasses?

2006-11-08 Thread Farshid Lashkari
John Salerno wrote: > Ok, back to my so-called "game." I'm just curious if I've implemented > the subclasses properly, because it seems like an awful lot of > repetition with the parameters. And again, if I want to add a new > attribute later, I'd have to change a lot of things. I can't help but

is this the right way to do subclasses?

2006-11-08 Thread John Salerno
Ok, back to my so-called "game." I'm just curious if I've implemented the subclasses properly, because it seems like an awful lot of repetition with the parameters. And again, if I want to add a new attribute later, I'd have to change a lot of things. I can't help but get the feeling that I'm d