Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37356

Re: Converting a string to a number by using INT (no hash method)

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 <python-python-list@m.gmane.org>
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 <wlfraed@ix.netcom.com>
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 <e74ae1aa-f760-4123-8770-3b8a4f9a2f91@googlegroups.com> <mailman.806.1358872054.2939.python-list@python.org> <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <mailman.812.1358875475.2939.python-list@python.org> <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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.842.1358893382.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, 22 Jan 2013 09:39:11 -0800 (PST), Ferrous Cranus
<nikos.gr33k@gmail.com> 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/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 08:15 -0800
  RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 16:27 +0000
    Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:02 -0800
      RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 17:24 +0000
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:39 -0800
          Re: Converting a string to a number by using INT (no hash method) John Gordon <gordon@panix.com> - 2013-01-22 18:36 +0000
          Re: Converting a string to a number by using INT  (no hash method) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-01-22 17:22 -0500
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:39 -0800
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 10:37 -0800
          Re: Converting a string to a number by using INT  (no hash method) Michael Torrie <torriem@gmail.com> - 2013-01-22 12:02 -0700
            Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 11:28 -0800
              Re: Converting a string to a number by using INT  (no hash method) Alan Spence <alan.spence@ntlworld.com> - 2013-01-22 20:00 +0000
            Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 11:28 -0800
              Re: Converting a string to a number by using INT (no hash method) John Gordon <gordon@panix.com> - 2013-01-22 20:40 +0000
                Re: Converting a string to a number by using INT (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-23 00:44 -0800
          Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 14:08 -0500
          RE: Converting a string to a number by using INT  (no hash method) "Leonard, Arah" <Arah.Leonard@bruker-axs.com> - 2013-01-22 20:30 +0000
          Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 15:43 -0500
        Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 10:37 -0800
    Re: Converting a string to a number by using INT  (no hash method) Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-22 09:02 -0800
  Re: Converting a string to a number by using INT  (no hash method) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-01-22 16:27 +0000
  Re: Converting a string to a number by using INT  (no hash method) Dave Angel <d@davea.name> - 2013-01-22 11:40 -0500
    Re: Converting a string to a number by using INT (no hash method) alex23 <wuwei23@gmail.com> - 2013-01-22 17:32 -0800
      Re: Converting a string to a number by using INT (no hash method) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-23 03:02 +0000
        Re: Converting a string to a number by using INT (no hash method) alex23 <wuwei23@gmail.com> - 2013-01-22 19:59 -0800
  Re: Converting a string to a number by using INT  (no hash method) "D'Arcy J.M. Cain" <darcy@druid.net> - 2013-01-22 12:04 -0500

csiph-web