Subclassing zipfile (new style class)

Tom Brown brown at esteem.com
Fri Sep 7 01:26:57 CEST 2007


On Thursday 06 September 2007 16:15, Larry Bates wrote:
> I'm trying to learn about subclassing new style classes and the first
> project I went to do needs to subclass zipfile to add some methods.
>
>
> Why does this:
>
> import zipfile
> class walkZip(zipfile):
>      pass
>
>
> if __name__ == "__main__":
>      print "Hello World"
>
> Traceback (most recent call last):
>    File "<string>", line 192, in run_nodebug
>    File "<module1>", line 2, in <module>
> TypeError: Error when calling the metaclass bases
>      module.__init__() takes at most 2 arguments (3 given)
>

I think because you need to do this:

from zipfile import ZipFile
class walkZip(ZipFile):
	pass


-Tom



More information about the Python-list mailing list