Confusion about python self usage
<p>I am writing a simple class that derives from HTMLParser and overrides the handle_starttag method. It will check if there is a class variable for each type of tag encountered; if not, it will create one and set the value equal to 1; if there is one, it will increment it. The purpose of this is to count the number of each type of tag on an HTML page.</p>

<pre><code>class MyHTMLParser(HTMLParser):
    def __init__(self):
        counts = {}

    def handle_starttag(self, tag, attrs):
        if not counts[tag]:
            counts[tag] = 1
        else:
            counts[tag] += 1
</code></pre>

<p>I get the following error:</p>

<pre><code>AttributeError: MyHTMLParser instance has no attribute 'rawdata'
</code></pre>

<p>What am I doing wrong?</p>
