[Tutor] super() with Multiple Inheritance
Alan Gauld
alan.gauld at btinternet.com
Thu Apr 14 19:25:45 CEST 2011
"James Thornton" <james at jamesthornton.com> wrote
> Why does user.params() not return all the params up the inheritance
> chain? -- It's not including the params defined in Person() --
> notice
> Vertex() does not have a params() method.
> class Element(object):
> def params(self):
> return dict(uuid=self.uuid, key=self.key)
>
> class Vertex(Element):
>
> class Person(Vertex):
> def params(self):
> params = dict(name=self.name,uri=self.uri,email=self.email)
> params.update(self.s.params())
> return params
>
> class User(Person):
> def params(self):
> params = dict(first_name=self.first_name,
> locale=self.locale)
> print self.s.params()
> params.update(self.s.params())
> return params
Where does User.params call Person.params?
Or for that matter Person.params call its super class?
It doesn't happen automatically(thank goodness) you
have to do it explicitly.
More information about the Tutor
mailing list