Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '%s"': 0.07; 'collections': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:method': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'innermost': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'running:': 0.16; 'subject:Converting': 0.16; 'jan': 0.18; 'import': 0.21; 'header:X-Complaints-To:1': 0.28; 'skip:- 10': 0.32; 'print': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'path': 0.35; 'received:org': 0.36; 'explain': 0.36; 'thank': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'please,': 0.62; '10000': 0.65; 'pin': 0.65; '2013': 0.84; 'collision': 0.84; '1972': 0.91; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Converting a string to a number by using INT (no hash method) Date: Tue, 22 Jan 2013 17:22:51 -0500 Organization: > Bestiaria Support Staff < References: <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <592233bd-3fc1-4e13-97f8-e11f89fbb0ba@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-99-200.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358893382 news.xs4all.nl 6933 [2001:888:2000:d::a6]:34663 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37356 On Tue, 22 Jan 2013 09:39:11 -0800 (PST), Ferrous Cranus declaimed the following in gmane.comp.python.general: > > Finally!!!!!! THANK YOU VERY MUCH!!! THIS IS WHAT I WAS LOOKING FOR!!! > > NOW, if you please explain it to me from the innermost parenthesis please, because i do want to understand it!!! > > And since i'am sure it works, and i just used it on http://superhost.gr Really: Try running: -=-=-=-=-=-=- import os import collections PATH = "c:/windows" #change this to your need fids = os.listdir(PATH) print "Number of files in directory %s: %s" % (PATH, len(fids)) cntr = collections.Counter() for fid in fids: pin = int( fid.encode("hex"), 16 ) % 10000 cntr.update([pin]) for pin, cnt in cntr.items(): if cnt > 1: print "%10s %10s COLLISION" % (pin, cnt) -=-=-=-=-=- Number of files in directory c:/windows: 290 9799 2 COLLISION 7209 2 COLLISION 8900 2 COLLISION 6985 2 COLLISION 1972 2 COLLISION 2532 2 COLLISION 3559 2 COLLISION -=-=-=-=-=- Number of files in directory e:/userdata/wulfraed/my documents/python progs: 157 1369 2 COLLISION 6041 3 COLLISION 3945 3 COLLISION 8489 2 COLLISION 7417 2 COLLISION 9076 2 COLLISION 6249 2 COLLISION 2457 2 COLLISION 937 2 COLLISION 8249 2 COLLISION -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/