[Tutor] hash.update( argv[0] )
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Mon Apr 24 07:49:00 CEST 2006
On Sun, 23 Apr 2006, George Georgalis wrote:
> Hi! I've been struggling to find a way up seed hash.update() with
> the sha1 (or similar) of the file that is the program running.
>
> this is not a security task but rather a means to generate
> reasonably unique filenames based on various parameters including
> changes to the program: name = hash.hexdigest()
>
> so new files are generated when the program or parameters are
> changed; but cached files are used when identical results are
> expected.
>
> help! I cannot figure out how to pass the program body as a seed
> to hash.update().
Hi George,
I'm slightly confused. Isn't this a matter of doing:
###################################################################
def prepare_md5(filename):
m = md5.new()
m.update(open(filename).read()) ## not so smart: do this
## progressively in real life!
return m
###################################################################
So I think I'm missing something.
Are you asking instead: how do I get the filename of the currently running
program?
More information about the Tutor
mailing list