Kent Tenney wrote: > Howdy, > > I would be interested in some discussion of > which of the following approaches is preferred and why. > > class RstManager: > > def __init__(self, text): > self.text = text > self.parseRst() > > def parseRst(self): > parsed = <do stuff to self.text> > self.parsed = parsed > > > class RstManager: > > def __init__(self, text): > self.parsed = parseRst(text) > > def parseRst(self, text): > parsed = <do stuff to text> > return parsed
If you have no further need of text, I prefer the second. If you need to keep text around then use the first one or possibly class RstManager: def __init__(self, text): self.text = text self.parsed = parseRst(text) def parseRst(self, text): parsed = <do stuff to text> return parsed which makes the assignment to self.parsed more explicit. Kent > > > Thanks, > Kent > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor