Re: sgmllib parser keeps old tag data?

2009-02-14 Thread Berend van Berkum
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Feb 13, 2009 at 03:41:52PM +, MRAB wrote: Berend van Berkum wrote: Yes.. tested that and SGMLParser won't let me override __init__, (SGMLParser vars are uninitialized even with sgmllib.SGMLParser(self) call). OK, so SGMLParser

sgmllib parser keeps old tag data?

2009-02-13 Thread Berend van Berkum
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, I read the source, made numerous tests, but SGMLParser's keeps returning *tag* data from previous parser instances. I'm totally confused why.. The content data it returns is ok. E.g.:: sp = MyParser() sp.feed('testt

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread MRAB
Berend van Berkum wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi everyone, I read the source, made numerous tests, but SGMLParser's keeps returning *tag* data from previous parser instances. I'm totally confused why.. The content data it returns is ok. E.g.:: sp = MyParser()

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread Berend van Berkum
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Feb 13, 2009 at 02:31:40PM +, MRAB wrote: Berend van Berkum wrote: import sgmllib class MyParser(sgmllib.SGMLParser): content = '' markup = [] span_stack = [] These are in the _class_ itself, so

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread MRAB
Berend van Berkum wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Feb 13, 2009 at 02:31:40PM +, MRAB wrote: Berend van Berkum wrote: import sgmllib class MyParser(sgmllib.SGMLParser): content = '' markup = [] span_stack = [] These are

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
you are declaring class variables, not instance variables. you need to declare these in an __init__ method. RTFM. http://docs.python.org/tutorial/classes.html#a-first-look-at-classes Berend van Berkum wrote: class MyParser(sgmllib.SGMLParser): content = '' markup = [] span_stack = []

Re: sgmllib parser keeps old tag data?

2009-02-13 Thread andrew cooke
Sorry, this reply was delayed (trying to use usenet...) and so now seems (even more) bad tempered than needed. Andrew andrew cooke wrote: you are declaring class variables, not instance variables. you need to declare these in an __init__ method. RTFM.