Am Sonntag 14 Mai 2006 22:29 schrieb Paul Rubin:
> Andrew Robert <[EMAIL PROTECTED]> writes:
> > When I run the script, I get an error that the file object does not have
> > the attribute getblocks.
>
> Woops, yes, you have to call getblocks(f). Also, Heiko says you can't
> use "return" to break
Andrew Robert <[EMAIL PROTECTED]> writes:
> When I run the script, I get an error that the file object does not have
> the attribute getblocks.
Woops, yes, you have to call getblocks(f). Also, Heiko says you can't
use "return" to break out of the generator; I thought you could but
maybe I got co
Am Sonntag 14 Mai 2006 20:51 schrieb Andrew Robert:
> def getblocks(f, blocksize=1024):
> while True:
> s = f.read(blocksize)
> if not s: return
> yield s
This won't work. The following will:
def getblocks(f,blocksize=1024):
while True:
When I run the script, I get an error that the file object does not have
the attribute getblocks.
Did you mean this instead?
def getblocks(f, blocksize=1024):
while True:
s = f.read(blocksize)
if not s: return
yield s
def getsum(self):
"Ant" <[EMAIL PROTECTED]> writes:
> def getSum(self):
> md5Sum = md5.new()
> f = open(self.filename, 'rb')
> for line in f:
> md5Sum.update(line)
> f.close()
> return md5Sum.hexdigest()
This should work, but there is one hazard if the file is ver
A script I use for comparing files by MD5 sum uses the following
function, which you may find helps:
def getSum(self):
md5Sum = md5.new()
f = open(self.filename, 'rb')
for line in f:
md5Sum.update(line)
f.close()
return md5Sum
Roy Smith wrote:
>>
>> However this does not appear to be actually returning the checksum.
>>
>> Does anyone have insight into where I am going wrong?
>
> After calling update(), you need to call digest(). Update() only updates
> the internal state of the md5 state machine; digest() returns the
In article <[EMAIL PROTECTED]>,
Andrew Robert <[EMAIL PROTECTED]> wrote:
> Good evening,
>
> I need to generate checksums of a file, store the value in a variable,
> and pass it along for later comparison.
>
> The MD5 module would seem to do the trick but I'm sketchy on implementation.
>
>
>
Actually, I think I got it but would like to confirm this looks right.
import md5
checksum = md5.new()
mfn = open(self.file_name, 'r')
for line in mfn.readlines():
checksum.update(line)
mfn.close()
cs = checksum.hexdigest()
print
Andrew Robert wrote:
> m=md5.new()
> contents = open(self.file_name,"rb").read()
> check=md5.update(contents)
>
> However this does not appear to be actually returning the checksum.
the docs are your friend, use them. hint: first you eat, then you...
http://docs.python.org/lib/module-md5.html
Good evening,
I need to generate checksums of a file, store the value in a variable,
and pass it along for later comparison.
The MD5 module would seem to do the trick but I'm sketchy on implementation.
The nearest I can see would be
import md5
m=md5.new()
contents = open(self.file_name,"rb").
11 matches
Mail list logo