How to derive a class from md5?
Josef Wolf
jw at raven.inka.de
Tue Jul 13 17:43:15 EDT 2004
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?
--
Please visit and sign http://petition-eurolinux.org and http://www.ffii.org
-- Josef Wolf -- jw at raven.inka.de --
More information about the Python-list
mailing list