Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.03; 'string.': 0.04; 'binary': 0.05; 'paths': 0.05; 'column': 0.07; 'python': 0.09; 'args,': 0.09; 'filename.': 0.09; 'indexes': 0.09; 'path)': 0.09; 'string)': 0.09; 'subject:method': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'index': 0.13; "skip:' 30": 0.15; '"unique"': 0.16; '12:57': 0.16; '794': 0.16; 'coding?': 0.16; 'costing': 0.16; 'easier.': 0.16; 'entries.': 0.16; 'happily': 0.16; 'ids.': 0.16; 'really?': 0.16; 'slashes': 0.16; 'uniqueness': 0.16; 'written.': 0.16; 'wed,': 0.16; 'string': 0.17; 'wrote:': 0.17; 'instance,': 0.17; 'integer': 0.17; 'skip': 0.17; 'subject:page': 0.17; 'test.': 0.17; 'jan': 0.18; '>>>': 0.18; 'python?': 0.20; 'file.': 0.20; 'sort': 0.21; 'supposed': 0.21; 'keys': 0.22; 'please?': 0.22; 'help.': 0.22; 'cc:2**0': 0.23; 'absolute': 0.23; 'this:': 0.23; "i've": 0.23; 'long,': 0.24; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'creating': 0.26; 'common': 0.26; 'am,': 0.27; 'there.': 0.28; 'actual': 0.28; 'chris': 0.28; 'fine': 0.28; 'run': 0.28; 'hosting': 0.28; '>>>>': 0.29; "d'aprano": 0.29; 'mode.': 0.29; 'piece': 0.29; 'steven': 0.29; 'unique,': 0.29; 'maybe': 0.29; 'that.': 0.30; 'expect': 0.31; 'code': 0.31; 'could': 0.32; 'idle': 0.33; 'instead,': 0.33; 'int': 0.33; 'subject: .': 0.33; 'likely': 0.33; 'produced': 0.33; 'received:google.com': 0.34; 'done': 0.34; 'returning': 0.35; 'skip:f 40': 0.35; 'so,': 0.35; 'expected': 0.35; 'table': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'should': 0.36; 'bad': 0.37; 'does': 0.37; 'two': 0.37; 'being': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'easily': 0.39; 'help': 0.40; 'end': 0.40; 'most': 0.61; 'chance': 0.61; "you'll": 0.62; 'between': 0.63; 'information': 0.63; 'more': 0.63; 'dont': 0.64; 'gave': 0.65; 'six': 0.65; '10,000': 0.65; 'pin': 0.65; 'response.': 0.67; '8bit%:100': 0.70; '8bit%:92': 0.70; 'foreign': 0.72; '2013': 0.84; 'compose': 0.84; 'relation.': 0.84; 'subject:Using': 0.84; 'tree,': 0.84; '1,000,000': 0.91; 'birthday': 0.91; 'indicator': 0.91; 'angel': 0.93; 'imagine': 0.96 X-Received: by 10.49.24.14 with SMTP id q14mr4607621qef.17.1358868088874; Tue, 22 Jan 2013 07:21:28 -0800 (PST) Newsgroups: comp.lang.python Date: Tue, 22 Jan 2013 07:21:28 -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: <50fe787e$0$30003$c3e8da3$5496439d@news.astraweb.com> <50fe8e69$0$30003$c3e8da3$5496439d@news.astraweb.com> <0459659d-4ec2-4c7d-bee3-b4e363c916dd@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: Using filepath method to identify an .html page 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: 248 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358868098 news.xs4all.nl 6923 [2001:888:2000:d::a6]:44122 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37283 =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 5:05:49 =CE=BC.=CE=BC. UTC+2, =CE=BF= =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Dave Angel =CE=AD=CE=B3=CF=81= =CE=B1=CF=88=CE=B5: > On 01/22/2013 09:55 AM, Ferrous Cranus wrote: >=20 > > =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 4:33:03 =CE=BC.=CE=BC. UTC+2, = =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Chris Angelico =CE=AD=CE= =B3=CF=81=CE=B1=CF=88=CE=B5: >=20 > >> On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus wrote: >=20 > >> >=20 > >>> =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 3:04:41 =CE=BC.=CE=BC. UTC+2, = =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Steven D'Aprano =CE=AD=CE= =B3=CF=81=CE=B1=CF=88=CE=B5: >=20 > >> >=20 > >>> >=20 > >> >=20 > >>>> What do you expect int("my-web-page.html") to return? Should it retu= rn 23 >=20 > >> >=20 > >>>> or 794 or 109432985462940911485 or 42? >=20 > >> >=20 > >>> >=20 > >> >=20 > >>> I expected a unique number from the given string to be produced so i = could have a (number <=3D> string) relation. What does int( somestring ) is= returning really? i don;t have IDLE to test. >=20 > >> >=20 > >> >=20 > >> >=20 > >> Just run python without any args, and you'll get interactive mode. You >=20 > >> >=20 > >> can try things out there. >=20 > >> >=20 > >> >=20 > >> >=20 > >>> This counter.py will work on a shared hosting enviroment, so absolute= s paths are BIG and expected like this: >=20 > >> >=20 > >>> >=20 > >> >=20 > >>> /home/nikos/public_html/varsa.gr/articles/html/files/index.html >=20 > >> >=20 > >> >=20 > >> >=20 > >> That's not big. Trust me, modern databases work just fine with unique >=20 > >> >=20 > >> indexes like that. The most common way to organize the index is with a >=20 > >> >=20 > >> binary tree, so the database has to look through log(N) entries. >=20 > >> >=20 > >> That's like figuring out if the two numbers 142857 and 857142 are the >=20 > >> >=20 > >> same; you don't need to look through 1,000,000 possibilities, you just >=20 > >> >=20 > >> need to look through the six digits each number has. >=20 > >> >=20 > >> >=20 > >> >=20 > >>> 'pin' has to be a number because if i used the column 'page' instead,= just imagine the database's capacity withholding detailed information for = each and every .html requested by visitors!!! >=20 > >> >=20 > >> >=20 > >> >=20 > >> Not that bad actually. I've happily used keys easily that long, and >=20 > >> >=20 > >> expected the database to ensure uniqueness without costing >=20 > >> >=20 > >> performance. >=20 > >> >=20 > >> >=20 > >> >=20 > >>> So i really - really need to associate a (4-digit integer <=3D> htmlp= age's absolute path) >=20 > >> >=20 > >> >=20 > >> >=20 > >> Is there any chance that you'll have more than 10,000 pages? If so, a >=20 > >> >=20 > >> four-digit number is *guaranteed* to have duplicates. And if you >=20 > >> >=20 > >> research the Birthday Paradox, you'll find that any sort of hashing >=20 > >> >=20 > >> algorithm is likely to produce collisions a lot sooner than that. >=20 > >> >=20 > >> >=20 > >> >=20 > >>> Maybe it can be done by creating a MySQL association between the two = columns, but i dont know how such a thing can be done(if it can). >=20 > >> >=20 > >>> >=20 > >> >=20 > >>> So, that why i need to get a "unique" number out of a string. please = help. >=20 > >> >=20 > >> >=20 > >> >=20 > >> Ultimately, that unique number would end up being a foreign key into a >=20 > >> >=20 > >> table of URLs and IDs. So just skip that table and use the URLs >=20 > >> >=20 > >> directly - much easier. In this instance, there's no value in >=20 > >> >=20 > >> normalizing. >=20 > >> >=20 > >> >=20 > >> >=20 > >> ChrisA >=20 > > >=20 > > I insist, perhaps compeleld, to use a key to associate a number to a fi= lename. >=20 > > Would you help please? >=20 > > >=20 > > I dont know this is supposed to be written. i just know i need this: >=20 > > >=20 > > number =3D function_that_returns_a_number_out_of_a_string( absolute_pat= h_of_a_html_file) >=20 > > >=20 > > Would someone help me write that in python coding? We are talkign 1 lin= e of code here.... >=20 > > >=20 >=20 >=20 > I gave you every piece of that code in my last response. So you're not= =20 >=20 > willing to compose the line from the clues? I cannot. I don't even know yet if hashing needs to be used for what i need. The only thing i know is that: a) i only need to get a number out of string(being an absolute path) b) That number needs to be unique, because "that" number is an indicator to= the actual html file. Would you help me write this in python? Why the hell=20 pin =3D int ( '/home/nikos/public_html/index.html' ) fails? because it has slashes in it?