HTML Parser - beginner needs help

Alex Martelli aleaxit at yahoo.com
Fri Sep 15 16:40:13 EDT 2000


"zet" <zet at i.com.ua> wrote in message
news:969039005.872906 at ipt2.iptelecom.net.ua...
> Thanx a lot guys.
> I've tried another way and it work (but it has one big minus).
>
> I change htmllib.py in this way:
>
>     def handle_image(self, src, alt, *args):
>         self.handle_data(alt)
>         self.imagelist.append(src)  # this line was added, and imegelist =
> [] in __init__
>
> Somewhat stupid, how do you think?

I think you've fallen straight into a typical anti-pattern: modifying
a component just because you have source.  You'll pay for the
mistake many times over, even if it's a small mod, like here.

Inherit from the class, override its method, and you have no
need for such changes, while achieving the same effect. *MUCH*
better.


Alex






More information about the Python-list mailing list