Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Newsgroups: comp.lang.python Subject: Re: new to python, help please !! Date: Thu, 12 Nov 2015 07:27:29 -0700 Lines: 40 Message-ID: References: <93aef8e5-3d6f-41f4-a625-cd3c2007686e@googlegroups.com> <5644005e$0$2932$c3e8da3$76491128@news.astraweb.com> <8737wbu49x.fsf@elektro.pacujo.net> <20151112054812.3603d4de@bigbox.christie.dr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de igMjkMxgHIfV+nmGtWNxTg/sQk4l2TQ77BqO278n8SIw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:help': 0.07; 'cc:addr:python-list': 0.09; 'chunk_size': 0.09; 'chunks': 0.09; 'eof': 0.09; 'to:addr:python.list': 0.09; 'to:addr:tim.thechases.com': 0.09; 'to:name:tim chase': 0.09; 'subject:python': 0.14; '-tkc': 0.16; '1024': 0.16; 'cmp': 0.16; 'md5': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'true:': 0.16; 'wrote:on': 0.16; 'wrote:': 0.16; '>': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'compare': 0.27; 'message-id:@mail.gmail.com': 0.27; 'large.': 0.29; 'url:mailman': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'nov': 0.35; 'subject:please': 0.35; 'should': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; '12,': 0.37; 'wanted': 0.37; 'received:209': 0.38; 'files': 0.38; 'url:mail': 0.40; 'some': 0.40; 'from:no real name:2**0': 0.60; 'skip:n 10': 0.62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=GZ1U2wQPKqErysN5v692Z/YspEo+eA6uk2/dLtLyT5o=; b=Nk7Wwcl1aFNPaNqseTIDboqem6Rf3cqFsBI20zr4zcYbsQSLjBI5pb+tkHELXwYsSF d3LqEuby7sawrPSCwpJu47GXTObrunQywqx9/NO0vX/fngCpAl2NVDTRhOaRvCEs3102 Ah/A4YUERpahLkWti1gzhv1pcoUat70eyD6TZE86h+5df/S29iEzZzT3scJ0d8vKa2Q5 LhJhReJHoTEfKbu2t6KjrQ6p7oDfiqZEQSpWzuIf1khg4Q6UsdiAg1/imW6kIYs0nuE4 gEgBH8DzhiPji6Jjt7RHmv9UAqY9TpideoC4PV5nOadtZki89EaGm03qWyKi6CV75sNl bFJQ== X-Received: by 10.112.61.166 with SMTP id q6mr2327023lbr.70.1447338449612; Thu, 12 Nov 2015 06:27:29 -0800 (PST) In-Reply-To: <20151112054812.3603d4de@bigbox.christie.dr> X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98697 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.md5') as f1, open('f2.md5') as f2: > > if f1.read() == f2.read(): > > ... > > else: > > ... > > Though that suffers if the files are large. Might try > > CHUNK_SIZE = 4 * 1024 # read 4k chunks > # chunk_offset = 0 > with open('f1.md5') as f1, open('f2.md5') as f2: > while True: > c1 = f1.read(CHUNK_SIZE) > c2 = f2.read(CHUNK_SIZE) > if c1 or c2: > # chunk_offset += 1 > if c1 != c2: > not_the_same(c1, c2) > # not_the_same(chunk_offset * CHUNK_SIZE, c1, c2) > break > else: # EOF > the_same() > break > > which should perform better if the files are huge > > -tkc > > > > -- > https://mail.python.org/mailman/listinfo/python-list >