Subclassing zipfile (new style class)

Farshid Lashkari no at spam.com
Thu Sep 6 19:25:55 EDT 2007


Larry Bates wrote:
> 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)

In your code 'zipfile' is a module, not a class, so you cannot inherit 
from it. I believe this is what you are trying to accomplish:

class walkZip(zipfile.ZipFile):
     pass

-Farshid



More information about the Python-list mailing list