[Tutor] Custom (non-standard) SGML Parser and OOP Problem

Magnus Lyckå magnus@thinkware.se
Mon May 19 06:01:01 2003


At 15:55 2003-05-18 -0400, Adam Kessel wrote:
>What's the right way to do this?  My question, boiled down, is: how to
>use sgmllib functionality but overwrite sgmllib internals without being a
>bad programmer?

I don't know if there is a perfect way, since you are obviously
bending sgmllib into being something it's not supposed to be. What
you want to parse isn't legal SGML, right?

I guess you could simply make a copy of sgmllib, call it something
else, and modify that. Then you won't be affected if sgmllib changes
its implementation so that your fix will no longer apply. I think
that's the best solution.

The backside is that you won't get improvements to sgmllib available
to your code, but maybe that's not a big loss. Since markupbase is not
a documented module, but internal for sgmllib and HTMLParser, you'd
better make a renamed copy of that as well and import and use that
in your modified version of sgmllib.



--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program