Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!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.001 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; 'index': 0.13; '"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; '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; 'sort': 0.21; 'supposed': 0.21; 'keys': 0.22; 'please?': 0.22; 'help.': 0.22; 'absolute': 0.23; 'this:': 0.23; "i've": 0.23; 'long,': 0.24; '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; '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; 'maybe': 0.29; 'that.': 0.30; 'expect': 0.31; 'code': 0.31; 'could': 0.32; 'idle': 0.33; 'instead,': 0.33; 'subject: .': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'produced': 0.33; 'done': 0.34; 'returning': 0.35; 'skip:f 40': 0.35; 'so,': 0.35; 'expected': 0.35; 'table': 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; 'subject:: ': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'easily': 0.39; 'received:192.168': 0.40; '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; 'response.': 0.67; '8bit%:100': 0.70; '8bit%:92': 0.70; 'received:74.208': 0.71; '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; 'imagine': 0.96 Date: Tue, 22 Jan 2013 10:05:49 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Using filepath method to identify an .html page References: <50fe787e$0$30003$c3e8da3$5496439d@news.astraweb.com> <50fe8e69$0$30003$c3e8da3$5496439d@news.astraweb.com> <0459659d-4ec2-4c7d-bee3-b4e363c916dd@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:rTF3XOq1EKBTz3XPTmt/te2WlIJM6+099vrQsKUVo/f +V8D/a1yGnQOaxIJyBHJn4trRq1CgWQW96Q1bKKlsIP3tr4V5X /CSXBH8CzhFKtOO6ExhwdamTYpDn68L/uYmpxI4L4HMK6bDrMv ExzqVYgGZZc8Zl8r2wuToftp/i6kWrO7q4dCyukTsBLj6QcEC3 pyMJMxMQ86Z3pSedBiOcm/H1J6WyTc9ioKsZ5e2Fidk4V5HYI7 E1IVkI5KL9FAv1JfPeCNkI1D8CyRoAmmRqjjQLA1OmDKDk/bJ3 a5yqLny+pTkY2LEoXDYQavxOVoEF7FxPQzUAFYEXOiwlRSNEw= = 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: 108 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358867171 news.xs4all.nl 6908 [2001:888:2000:d::a6]:60498 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37278 On 01/22/2013 09:55 AM, Ferrous Cranus wrote: > Τη Τρίτη, 22 Ιανουαρίου 2013 4:33:03 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε: >> On Wed, Jan 23, 2013 at 12:57 AM, Ferrous Cranus wrote: >> >>> Τη Τρίτη, 22 Ιανουαρίου 2013 3:04:41 μ.μ. UTC+2, ο χρήστης Steven D'Aprano έγραψε: >> >>> >> >>>> What do you expect int("my-web-page.html") to return? Should it return 23 >> >>>> or 794 or 109432985462940911485 or 42? >> >>> >> >>> I expected a unique number from the given string to be produced so i could have a (number <=> string) relation. What does int( somestring ) is returning really? i don;t have IDLE to test. >> >> >> >> Just run python without any args, and you'll get interactive mode. You >> >> can try things out there. >> >> >> >>> This counter.py will work on a shared hosting enviroment, so absolutes paths are BIG and expected like this: >> >>> >> >>> /home/nikos/public_html/varsa.gr/articles/html/files/index.html >> >> >> >> That's not big. Trust me, modern databases work just fine with unique >> >> indexes like that. The most common way to organize the index is with a >> >> binary tree, so the database has to look through log(N) entries. >> >> That's like figuring out if the two numbers 142857 and 857142 are the >> >> same; you don't need to look through 1,000,000 possibilities, you just >> >> need to look through the six digits each number has. >> >> >> >>> '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!!! >> >> >> >> Not that bad actually. I've happily used keys easily that long, and >> >> expected the database to ensure uniqueness without costing >> >> performance. >> >> >> >>> So i really - really need to associate a (4-digit integer <=> htmlpage's absolute path) >> >> >> >> Is there any chance that you'll have more than 10,000 pages? If so, a >> >> four-digit number is *guaranteed* to have duplicates. And if you >> >> research the Birthday Paradox, you'll find that any sort of hashing >> >> algorithm is likely to produce collisions a lot sooner than that. >> >> >> >>> 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). >> >>> >> >>> So, that why i need to get a "unique" number out of a string. please help. >> >> >> >> Ultimately, that unique number would end up being a foreign key into a >> >> table of URLs and IDs. So just skip that table and use the URLs >> >> directly - much easier. In this instance, there's no value in >> >> normalizing. >> >> >> >> ChrisA > > I insist, perhaps compeleld, to use a key to associate a number to a filename. > Would you help please? > > I dont know this is supposed to be written. i just know i need this: > > number = function_that_returns_a_number_out_of_a_string( absolute_path_of_a_html_file) > > Would someone help me write that in python coding? We are talkign 1 line of code here.... > I gave you every piece of that code in my last response. So you're not willing to compose the line from the clues? -- DaveA