Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.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; 'algorithm': 0.03; 'chunk': 0.07; 'compression': 0.09; 'filenames,': 0.09; 'page)': 0.09; 'path)': 0.09; 'path.': 0.09; 'subject:method': 0.09; 'subject:number': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'thrown': 0.09; '4-digit': 0.16; 'anyone?': 0.16; 'great!': 0.16; 'mathematics.': 0.16; 'subject:Converting': 0.16; 'wrote:': 0.17; 'examples': 0.18; 'requests': 0.18; 'programming': 0.23; 'absolute': 0.23; "i've": 0.23; 'script': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'done.': 0.27; 'actual': 0.28; 'post': 0.28; 'convert': 0.29; 'choices': 0.33; 'point,': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'knowledge': 0.33; 'path': 0.35; 'problem,': 0.35; 'but': 0.36; 'turn': 0.36; 'skip:4 10': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'gives': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; 'back': 0.62; 'information': 0.63; 'dont': 0.64; 'here': 0.65; 'received:74.208': 0.71; 'literature': 0.84; 'response,': 0.93 Date: Tue, 22 Jan 2013 11:40:57 -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: Converting a string to a number by using INT (no hash method) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:Hz+3YJoW8JsVFOZyXQvuwVg8ZTmWOa5xPOeXsnqJkN2 qaCX8LzjbxWnMrzCnrnrHJY89LLK0NdVYzmSncv9kfkUnf0QyD 6DPq0ttXR4e6mw5pou7UB5W3onKPIdC7+9Qi6zcJUaqgmIAqOK ilQ15WSlASIb7CN1FImXmtBobxiUBc3cXyX+KD+cSGeyJoCz4o p3W8CI52EpsUt+3h0QUfoEeCTNee1FwzArOw6EAZbYEbTe4ScT AdmO4iQ8FJZElWno+KH+j6Bg9Ai4kc62MJQurngYgfoZ7GAkaH DK65JiA/TAxwxNe0LK7DrgdZT2aRH4qWzmu3UlW6XxUYvSxyw= = 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358872879 news.xs4all.nl 6876 [2001:888:2000:d::a6]:56423 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37304 On 01/22/2013 11:15 AM, Ferrous Cranus wrote: > I just need a way to CONVERT a string(absolute path) to a 4-digit unique number with INT!!! That's all i want!! But i cannot make it work :( > > And the best part is that "that" number must be able to turn back into a path. > > This way i DON'T EVEN HAVE TO STORE THE ACTUAL HTML PAGE'S ABSOLUTE PATH!!!! > > 1. User requests a specific html page( .htaccess gives my script the absolute path for that .html page) > 2. I turn the path into a 4-digitnumber > 3. i store that number to the database. I DONT EVEN HAVE TO STORE THE PATH TO THE DATABASE ANYMORE!!! this is just great! > I had prepared a detailed response, showing what your choices are with this new constraint. But I can see from this post here that there's no point, so I've thrown it out. Either you're trolling, or you have a very limited knowledge of mathematics. This isn't a programming problem, it's a simple problem of information theory. Unless you constrain your users to very restrictive filenames, what you ask here simply cannot be done. Perpetual motion machine, anyone? Or a compression algorithm which can be applied repeatedly to a chunk of data until it shrinks down to one byte? No way to do it without cheating, and the literature is full of examples of people cheating. -- DaveA