Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'algorithm': 0.03; 'interpreter': 0.04; 'ascii': 0.07; 'python': 0.09; 'alan': 0.09; 'subject:method': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'coding?': 0.16; 'hexadecimal': 0.16; 'merely': 0.16; 'parser.': 0.16; 'subject:Converting': 0.16; 'wrote:': 0.17; 'string,': 0.17; 'jan': 0.18; '>>>': 0.18; 'to:name:python-list@python.org': 0.20; 'produces': 0.22; 'stopping': 0.22; 'posted': 0.22; 'work.': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'implemented': 0.27; 'pages,': 0.27; 'converting': 0.27; 'opposed': 0.27; 'this?': 0.28; 'run': 0.28; 'hash': 0.29; 'mod': 0.29; 'perl': 0.29; 'url:mailman': 0.29; 'character': 0.29; 'objects': 0.29; 'class': 0.29; 'code': 0.31; 'url:python': 0.32; 'file': 0.32; 'could': 0.32; 'url:listinfo': 0.32; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'wrong': 0.34; 'doing': 0.35; 'received:209.85': 0.35; 'explain': 0.36; 'michael': 0.36; 'url:org': 0.36; 'characters': 0.36; 'method': 0.36; 'being': 0.37; 'why': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'received:192': 0.39; 'short': 0.39; 'received:192.168': 0.40; 'url:mail': 0.40; 'map': 0.61; 'header:Message-Id:1': 0.62; 'results': 0.65; 'taking': 0.65; '10000': 0.65; 'differences': 0.65; 'pin': 0.65; '8bit%:100': 0.70; '8bit%:92': 0.70; 'url:htm': 0.71; '2013': 0.84; 'technically': 0.91 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=0ObnxyXQN3MNWMjscuKDr7gUfVbM3anZ0pAyEf+OZkU=; b=Y0H3aYPFR/qoBw5fKtWGmtszNHWTZErZlkJMqwKe0/phbPynpsomn7O9Djl99zjaHc NKPUkNHIeWdoKWgt2MBW80/rrIxtoW3TY+xbQYNLnjLjByJ5BkqCvLhhpOFUtNg92fNT u/MIFpNafBxISclpuAQqI28iDJh7bppZdN+tzeQ22M9MFDN7uI0Wax9v+9yBOB4oCEHB A+vwHVCmi0w7Nf5oJJsSJDsaQk6tgkJTkEI/1UBCBpyW0t6GlATonnMLwpaVVmi6nNTD 5y0HgreCW6FADSBDDR8RdND0bRfwJ6fQOdLlVdt0YXLBLuxCeJKD/vYLSfXTZIwrhboo XQGw== X-Received: by 10.204.4.199 with SMTP id 7mr5242030bks.15.1358884816692; Tue, 22 Jan 2013 12:00:16 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: Converting a string to a number by using INT (no hash method) From: Alan Spence In-Reply-To: <97e31693-5928-4e43-bc97-c449118f2de0@googlegroups.com> Date: Tue, 22 Jan 2013 20:00:12 +0000 Content-Transfer-Encoding: quoted-printable References: <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <2de57cf7-4a8f-4304-91cf-0024963315d7@googlegroups.com> <97e31693-5928-4e43-bc97-c449118f2de0@googlegroups.com> To: "python-list@python.org" X-Mailer: Apple Mail (2.1499) X-Gm-Message-State: ALoCoQlkz4hRQovopRSrf9dGJvL5XqhH39771oLxmm0Hsb9xYdnrqdiq1yN7Bc4iX4eHaKRBfcyp 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: 98 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358885133 news.xs4all.nl 6912 [2001:888:2000:d::a6]:42685 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37343 On 22 Jan 2013, at 19:28, Ferrous Cranus wrote: > =CE=A4=CE=B7 =CE=A4=CF=81=CE=AF=CF=84=CE=B7, 22 =CE=99=CE=B1=CE=BD=CE=BF= =CF=85=CE=B1=CF=81=CE=AF=CE=BF=CF=85 2013 9:02:48 =CE=BC.=CE=BC. UTC+2, = =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Michael Torrie = =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: >> On 01/22/2013 11:37 AM, Ferrous Cranus wrote: >>=20 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D pin =3D= int( >>=20 >>> htmlpage.encode("hex"), 16 ) % 10000=20 >>=20 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>=20 >>>=20 >>=20 >>> Can you please explain the differences to what you have posted >>=20 >>> opposed to this perl coding? >>=20 >>>=20 >>=20 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = foreach my >>=20 >>> $ltr(@ltrs){ $hash =3D ( $hash + ord($ltr)) %10000;=20 >>=20 >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>=20 >>>=20 >>=20 >>> I want to understand this and see it implemented in Python. >>=20 >>=20 >>=20 >> It isn't quite the thing. The perl code is merely a checksum of the >>=20 >> ascii value of the characters in the file name, that is then chopped >>=20 >> down to a number < 10000. The Python code is taking the ascii value = of >>=20 >> each character in the file name, converting it to a hexadecimal pair = of >>=20 >> digits, stringing them all out into a long string, then converting = that >>=20 >> to a number using the hexadecimal number parser. This results in a >>=20 >> *very* large number, 8-bits per letter in the original file name, and >>=20 >> then chops that down to 10000. Technically neither method is a hash = and >>=20 >> neither will generate unique numbers. >>=20 >>=20 >>=20 >> Here's the python algorithm used on a short word: >>=20 >> 'hello' =3D> '68656c6c6f' (h =3D 0x68', e=3D0x65', 0x6c', 0=3D0x6f) >>=20 >> =3D> 0x68656c6c6f =3D> 448378203247 >>=20 >> mod that with 10000 and you get 3247 >>=20 >>=20 >>=20 >> If you would simply run the python interpreter and try these things = out >>=20 >> you could see how and why they work or not work. What is stopping = you >>=20 >> from doing this? >=20 >=20 > May i sent you my code by mail so for you see whats wrong and = http://superhost.gr produces error?

>=20 > 1. this is not a script that iam being paid for. > 2, this is not a class assignemnt >=20 > I just want to use that method of gettign this to work. > --=20 > http://mail.python.org/mailman/listinfo/python-list All pages, strings and objects map to: http://redwing.hutman.net/~mreed/warriorshtm/ferouscranus.htm Alan=