[Tutor] dictionary looping problem

Jeremiah Jester jeremiah.jester at panasonic.aero
Tue Dec 2 23:26:40 CET 2008


Thanks for clearing this up for me. 

On Tue, 2008-12-02 at 13:25 -0800, Steve Willoughby wrote:
> On Tue, Dec 02, 2008 at 01:08:09PM -0800, Jeremiah Jester wrote:
> > Hello,
> >
> > I'm trying to gather a list of files and md5 hash them to do a
> checksum.
> > I've created a function for each dictionary. However, when i print
> out
> > the dictionary I don't get all the items. Any ideas?
> 
> Yep.  Don't use os.system() there. 
> 
> 1. you're running the "md5" program externally when you don't need to,
>    since Python has the ability to compute md5 checksums on its own,
>    which you already know because you imported that module at the top
>    of your script (and then didn't use).
> 
> 2. The return value from os.system() is NOT the hash, so what you're
>    storing in the dictionary is not going to be that unique, and so
>    each call which yields the same return value (0, usually) will
>    overwrite that element in the dict.
> 
> --
> Steve Willoughby    |  Using billion-dollar satellites
> steve at alchemy.com   |  to hunt for Tupperware.
> 
> 
> 



Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.




More information about the Tutor mailing list