Problem with sha.new
John Machin
sjmachin at lexicon.net
Sat Jul 9 08:14:07 EDT 2005
Florian Lindner wrote:
> Hello,
> I try to compute SHA hashes for different files:
>
>
> for root, dirs, files in os.walk(sys.argv[1]):
> for file in files:
> path = os.path.join(root, file)
> print path
> f = open(path)
print "sha is", repr(sha) ### self-help !!!!!
> sha = sha.new(f.read())
print "sha is", repr(sha) ### self-help !!!!!
> sha.update(f.read())
> print sha.hexdigest()
>
>
> this generates a traceback when sha.new() is called for the second time:
>
> /home/florian/testdir/testfile
> c95ad0ce54f903e1568facb2b120ca9210f6778f
> /home/florian/testdir/testfile2
> Traceback (most recent call last):
> File "duplicatefinder.py", line 11, in ?
> sha = sha.new(f.read())
> AttributeError: new
>
> What is wrong there?
>
"sha" no longer refers to the module of that name; it refers to the
sha-object returned by the FIRST call of sha.new. That sha-object
doesn't have a method called "new", hence the AttributeError exception.
More information about the Python-list
mailing list