16
IS there any magic I can use in Python to to effectively use super constructor by just adding some extra arguments?
Ideally I'd like to use something like:
class ZipArchive(zipfile.ZipFile):
def __init__(self, verbose=True, **kwargs):
"""
Constructor with some extra params.
For other params see: zipfile.ZipFile
"""
self.verbose = verbose
super(ZipArchive, self).__init__(**kwargs)
And then be able to use the original constructor arguments mixed with some extra stuff from my class. Like so:
zip = ZipArchive('test.zip', 'w')
zip = ZipArchive('test.zip', 'w', verbose=False)
I'm using Python 2.6, but if the magic can only be achieved in higher version of Python then I'm interested too.
EDIT: I should probably mention that above doesn't work. The error is: TypeError: __init__() takes at most 2 arguments (3 given)