J
Josef Wolf
Hello!
I'd like to create a class to calculate md5's of a file. So I thought, I'd
derive from the md5 class. I came up with following code:
#!/usr/bin/python
import md5
class md5file(md5):
def __init__(self, filename):
md5.__init__(self)
f=file(filename,"r")
for l in f:
self.update(l)
f.close()
print md5file("/etc/passwd").hexdigest()
But running this gives me the following error:
Traceback (most recent call last):
File "py/t.py", line 5, in ?
class md5file(md5):
TypeError: function takes at most 2 arguments (3 given)
dir(md5) shows that md5 don't have an __init__() method so I tried to use
its new(), with the same result. What am I doing wrong here?
I'd like to create a class to calculate md5's of a file. So I thought, I'd
derive from the md5 class. I came up with following code:
#!/usr/bin/python
import md5
class md5file(md5):
def __init__(self, filename):
md5.__init__(self)
f=file(filename,"r")
for l in f:
self.update(l)
f.close()
print md5file("/etc/passwd").hexdigest()
But running this gives me the following error:
Traceback (most recent call last):
File "py/t.py", line 5, in ?
class md5file(md5):
TypeError: function takes at most 2 arguments (3 given)
dir(md5) shows that md5 don't have an __init__() method so I tried to use
its new(), with the same result. What am I doing wrong here?