Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'algorithm': 0.03; 'interpreter': 0.04; 'ascii': 0.07; 'python': 0.09; 'subject:method': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'coding?': 0.16; 'hexadecimal': 0.16; 'merely': 0.16; 'parser.': 0.16; 'subject:Converting': 0.16; 'wrote:': 0.17; 'string,': 0.17; 'produces': 0.22; 'stopping': 0.22; 'posted': 0.22; 'cc:2**0': 0.23; 'work.': 0.23; 'cc:no real name:2**0': 0.24; 'script': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'am,': 0.27; 'implemented': 0.27; 'converting': 0.27; 'opposed': 0.27; 'this?': 0.28; 'run': 0.28; 'hash': 0.29; 'mod': 0.29; 'perl': 0.29; 'character': 0.29; 'class': 0.29; 'code': 0.31; 'file': 0.32; 'could': 0.32; 'received:google.com': 0.34; 'wrong': 0.34; 'doing': 0.35; 'received:209.85': 0.35; 'explain': 0.36; 'michael': 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; 'short': 0.39; 'results': 0.65; 'taking': 0.65; '10000': 0.65; 'differences': 0.65; 'pin': 0.65; '8bit%:100': 0.70; '8bit%:92': 0.70; '2013': 0.84; 'technically': 0.91 X-Received: by 10.50.159.197 with SMTP id xe5mr4477563igb.3.1358882937095; Tue, 22 Jan 2013 11:28:57 -0800 (PST) Newsgroups: comp.lang.python Date: Tue, 22 Jan 2013 11:28:55 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.68.70.179; posting-account=DYJQ-woAAACEPH85Au2BhUVfFTfSfVa4 References: <4339f8d7-2d78-450f-ad0e-91da35615e6d@googlegroups.com> <2de57cf7-4a8f-4304-91cf-0024963315d7@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.68.70.179 MIME-Version: 1.0 Subject: Re: Converting a string to a number by using INT (no hash method) From: Ferrous Cranus To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: , Message-ID: Lines: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358882946 news.xs4all.nl 6969 [2001:888:2000:d::a6]:55061 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37339 =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 forea= ch 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? May i sent you my code by mail so for you see whats wrong and http://superh= ost.gr produces error?

1. this is not a script that iam being paid for. 2, this is not a class assignemnt I just want to use that method of gettign this to work.