Method returns self?
Roy Smith
roy at panix.com
Fri Oct 19 07:50:51 EDT 2001
Ignacio Vazquez-Abrams <ignacio at openservices.net> wrote:
> Another thing you could do, if you plan to have more than one possible format,
> is to have myParser.parse() do the verification of the data and return a
> myData1, myData2, etc. object depending on the format.
Actually, I do that already. The data class has several subclasses, and
the parser returns the right one. Each data subclass would have its own
verify() method. Actually, more likely the base data class will also have
a verify() method, and each subclass's verify() will call data.verify(),
then do its own additional checking.
Another problem I have is that I'm in a running argument with a coworker
about what's syntax (i.e. should be checked in the parser) and what's
semantics (and should be checked in data.verify()), but that's a problem
we'll have to solve on our own :-)
More information about the Python-list
mailing list