tags:

views:

202

answers:

1

Let me start by saying, I also get the same error whey defining __init__ and running super()'s __init__. I only simplified it down to this custom method to see if the error still happened.

import HTMLParser


class Spider(HTMLParser):
    def spamfoo(self):
        print('some random non-overriding method')

This alone in a module raises the following error:

Traceback (most recent call last):
  File "D:\my\path\to\my\file
    class Spider(HTMLParser):
TypeError: Error when calling the metaclass bases
    module.__init__() takes at most 2 arguments (3 given)
+5  A: 

And the answer is that I'm a complete noob. This is a module, not a class, but I'll leave this up here in case other noobs run into the same problem.

Solution:

from HTMLParser import HTMLParser

Each time I think I'm starting to become a pro, something like this happens :(

orokusaki
I don't know, I could actually see this tripping up a lot of people, having the module and the class within the module named the same.
BigBeagle
I think there's a quite a range of existence between `complete noob` and `pro`.
MattH
To avoid namespace pollution, you could use:`import HTMLParser``class Spider(HTMLParser.HTMLParser)`
GreenMatt
(deleted a set of comments with multiple flags from multiple users; off-topic to the question)
Marc Gravell
I do this sort of thing with modules like `StringIO` and `timeit` all the time. And `datetime`. Don't get me started on `datetime`.
Robert Rossney