file.getvalue() with _ or other characters

Peter Otten __peter__ at web.de
Fri Mar 4 10:38:09 CET 2005


martijn at gamecreators.nl wrote:

> class mvbHTMLParser(htmllib.HTMLParser):
>     def __init__(self, formatter, verbose=0):
>         htmllib.HTMLParser.__init__(self,formatter,verbose)
    
      def anchor_end(self):
          self.anchor = None

[...]

> then the output is:
> text_text
> a_link[1]
> 
> that's oke but how to delete [n]
> like this? : del = re.compile(r'[0-9]',).sub

Overriding the anchor_end() method as shown above will suppress the [n]
suffix after links.

Peter




More information about the Python-list mailing list