Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote: > i am a beginning programmer, i am trying to write a simple code to > compare two character sets in 2 seperate files. ( 2 hash value files > basically) Why? If you simply wish to compare two files, most operating systems provide executa

Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
On Thu, 12 Nov 2015 17:55:33 +, Quivis wrote: > On Thu, 12 Nov 2015 13:58:35 +1100, Steven D'Aprano wrote: > >> horribly inefficient > > Assuming it was md5 values, who cares? Those are small. A file of 160 million md5 hashes as 32 character hex strings is a huge file. Your method calculat

Re: new to python, help please !!

2015-11-12 Thread Peter Otten
Tim Chase wrote: > On 2015-11-12 15:56, Peter Otten wrote: >> Tim Chase wrote: >> >> > with open("file1.md5") as a, open("file2.md5") as b: >> > for s1, s2 in zip(a, b): >> > if s1 != s2: >> > print("Files differ") >> >> Note that this will not detect extra lines in one of th

Re: new to python, help please !!

2015-11-12 Thread Tim Chase
On 2015-11-12 15:56, Peter Otten wrote: > Tim Chase wrote: > > > with open("file1.md5") as a, open("file2.md5") as b: > > for s1, s2 in zip(a, b): > > if s1 != s2: > > print("Files differ") > > Note that this will not detect extra lines in one of the files. > I recommend that

Re: new to python, help please !!

2015-11-12 Thread Peter Otten
Tim Chase wrote: > with open("file1.md5") as a, open("file2.md5") as b: > for s1, s2 in zip(a, b): > if s1 != s2: > print("Files differ") Note that this will not detect extra lines in one of the files. I recommend that you use itertools.zip_longest (izip_longest in Python 2)

Re: new to python, help please !!

2015-11-12 Thread paul.hermeneutic
Would some form of subprocess.Popen() on cmp or fc /b be easier? On Nov 12, 2015 7:13 AM, "Tim Chase" wrote: > On 2015-11-12 08:21, Marko Rauhamaa wrote: > > And if you really wanted to compare two files that are known to > > contain MD5 checksums, the simplest way is: > > > >with open('f1.md

Re: new to python, help please !!

2015-11-12 Thread Tim Chase
On 2015-11-12 08:21, Marko Rauhamaa wrote: > And if you really wanted to compare two files that are known to > contain MD5 checksums, the simplest way is: > >with open('f1.md5') as f1, open('f2.md5') as f2: >if f1.read() == f2.read(): >... >else: >... T

Re: new to python, help please !!

2015-11-11 Thread Marko Rauhamaa
Steven D'Aprano : > On Thursday 12 November 2015 04:48, Quivis wrote: > >> On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote: >> >>> md5 >> >> If those are md5 values stored inside files, wouldn't it be easier to >> just hash them? >> >> import hashlib >> >> m1 = hashlib.sha224(open('f1'

Re: new to python, help please !!

2015-11-11 Thread Steven D'Aprano
On Thursday 12 November 2015 04:48, Quivis wrote: > On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote: > >> md5 > > If those are md5 values stored inside files, wouldn't it be easier to > just hash them? > > import hashlib > > m1 = hashlib.sha224(open('f1').read()).hexdigest() > m2 = has

Re: new to python, help please !!

2015-11-11 Thread Ben Finney
Anas Belemlih writes: > i am a beginning programmer, i am trying to write a simple code to > compare two character sets in 2 seperate files. ( 2 hash value files > basically) Welcome, and congratulations on arriving at Python for your programming! As a beginning programmer, you will benefit f

Re: new to python, help please !!

2015-11-11 Thread Tim Chase
On 2015-11-11 08:34, Anas Belemlih wrote: > i am a beginning programmer, i am trying to write a simple code > to compare two character sets in 2 seperate files. ( 2 hash value > files basically) idea is: open both files, measure the length of > the loop on. > > if the length doesn't match, ==

Re: new to python, help please !!

2015-11-11 Thread John Gordon
In <93aef8e5-3d6f-41f4-a625-cd3c20076...@googlegroups.com> Anas Belemlih writes: > i=0 > s1=line1[i] > s2=line2[i] > count = 0 > if number1 != number2: > print " hash table not the same size" > else: > while count < number1: > if s1 == s2: > print " character", lin

new to python, help please !!

2015-11-11 Thread Anas Belemlih
i am a beginning programmer, i am trying to write a simple code to compare two character sets in 2 seperate files. ( 2 hash value files basically) idea is: open both files, measure the length of the loop on. if the length doesn't match, == files do not match if length matchs, loop while c