I found this issue -- I was setting setting self.s to the return value of super() and trying to use self.s in params():
self.s = super(User,self) self.s.__init__(name,uri,email) def params(self): params = dict(name=self.name) params.update(self.s.params()) ...but this won't work. You have to use super each time you want to make a call to a parent's function. It returns an object with an internal queue. If you use this object twice, you will only call the method of the top class (in this case, Element). super does not return an object from the parent class. It is a mechanism from managing multiple inheritance On Thu, Apr 14, 2011 at 12:25 PM, Alan Gauld <alan.ga...@btinternet.com> wrote: > > "James Thornton" <ja...@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. > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Latest Blog: http://jamesthornton.com/blog/how-to-get-to-genius _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor