Re: An inheritance question: getting the name of the one up class

2009-03-31 Thread Steven D'Aprano
On Tue, 31 Mar 2009 01:29:50 -0300, Gabriel Genellina wrote: Oh, and while the gurus are at it, what would be the advantage (if any) of changing, say Primate.__init__(self) to super(Human, self).__init__() None, if you use single inheritance everywhere. But there's no

Re: An inheritance question: getting the name of the one up class

2009-03-31 Thread Michele Simionato
On Mar 31, 5:13 am, Nick mediocre_per...@hotmail.com wrote: Oh, and while the gurus are at it, what would be the advantage (if any) of changing, say    Primate.__init__(self) to     super(Human, self).__init__() What others said. In Python 3.0 you would have a bigger advantage, since you

Re: An inheritance question: getting the name of the one up class

2009-03-31 Thread Nick
Thanks for the replies. This has given me some incentive to start looking at Python 3. Oh, and thanks for the articles on super(). Nick -- http://mail.python.org/mailman/listinfo/python-list

Re: An inheritance question: getting the name of the one up class

2009-03-31 Thread Gabriel Genellina
En Tue, 31 Mar 2009 05:16:47 -0300, Steven D'Aprano ste...@remove.this.cybersource.com.au escribió: On Tue, 31 Mar 2009 01:29:50 -0300, Gabriel Genellina wrote: Oh, and while the gurus are at it, what would be the advantage (if any) of changing, say Primate.__init__(self) to

An inheritance question: getting the name of the one up class

2009-03-30 Thread Nick
I've got a collection of classes describing animals, part of which looks like: class Animal(object): def __init__(self): self.pet = False self.edible = False self.legs = 0 self.sound = None self.name = self.__class__.__name__.lower() class Mammal(Animal):

Re: An inheritance question: getting the name of the one up class

2009-03-30 Thread Gabriel Genellina
En Tue, 31 Mar 2009 00:13:44 -0300, Nick mediocre_per...@hotmail.com escribió: I've got a collection of classes describing animals, part of which looks like: class Animal(object): def __init__(self): self.pet = False self.edible = False self.legs = 0

Re: An inheritance question: getting the name of the one up class

2009-03-30 Thread alex23
On Mar 31, 1:13 pm, Nick mediocre_per...@hotmail.com wrote: I want to add a pedigree function to Animal so that I can have: h = Human() h.pedigree() human primate mammal animal class Animal(object): @classmethod def pedigree(cls): return [c.__name__ for c in cls.mro()