Using filepath method to identify an .html page

Ferrous Cranus nikos.gr33k at gmail.com
Tue Jan 22 19:07:21 CET 2013


Τη Τρίτη, 22 Ιανουαρίου 2013 6:55:02 μ.μ. UTC+2, ο χρήστης John Gordon έγραψε:
> In <mailman.801.1358870401.2939.python-list at python.org> Ferrous Cranus <nikos.gr33k at gmail.com> writes:
> 
> 
> 
> > 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 :(
> 
> 
> 
> Given your requirements, I don't think it *can* work.  There's just no
> 
> way to do it.
> 
> 
> 
> How can the computer guarantee that billions of possible inputs (file paths)
> 
> map to 10,000 unique outputs (4-digit numbers)?  It's not possible.
> 
> 
> 
> It might be possible if you had control over the format of the input strings,
> 
> but it doesn't sound like you do.
> 
> 
> 
> Can you maintain a separate database which maps file paths to numbers?
> 
> If so, then this is an easy problem.  Just keep a lookup table, like so:
> 
> 
> 
>   filepath                                         number
> 
>   --------                                         ------
> 
>   /home/files/bob/foo.html                         0001
> 
>   /home/files/bob/bar.html                         0002
> 
>   /home/files/steve/recipes/chocolate-cake.html    0003
> 
>   /home/files/mary/payroll.html                    0004
> 
> 
> 
> -- 
> 
> John Gordon                   A is for Amy, who fell down the stairs
> 
> gordon at panix.com              B is for Basil, assaulted by bears
> 
>                                 -- Edward Gorey, "The Gashlycrumb Tinies"

No, because i DO NOT WANT to store LOTS OF BIGS absolute paths in the database.

And the .html files are not even close 10.000



More information about the Python-list mailing list