Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'win32': 0.03; 'interpreter': 0.04; 'data:': 0.07; 'exist,': 0.07; 'referring': 0.07; 'valueerror:': 0.07; 'python': 0.09; '%s",': 0.09; '16)': 0.09; 'file"': 0.09; 'here?': 0.09; 'literal': 0.09; 'path)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:method': 0.09; "skip:' 30": 0.15; '(%s)",': 0.16; '12)': 0.16; '2.7.2': 0.16; 'inc.)': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'slashes': 0.16; 'string': 0.17; 'integer': 0.17; 'subject:page': 0.17; 'jan': 0.18; 'shell': 0.18; '>>>': 0.18; 'python?': 0.20; 'file.': 0.20; 'bit': 0.21; '"",': 0.22; 'absolute': 0.23; 'command': 0.24; 'values': 0.26; '(most': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'actual': 0.28; 'decimal': 0.29; 'unique,': 0.29; '"the': 0.29; 'file': 0.32; 'running': 0.32; 'could': 0.32; 'int': 0.33; 'subject: .': 0.33; 'traceback': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'path': 0.35; 'something': 0.35; 'received:org': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'mean': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'help': 0.40; 'more': 0.63; 'pin': 0.65; '12:': 0.84; '13)': 0.84; '2013': 0.84; 'subject:Using': 0.84; 'dennis': 0.91; 'indicator': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Using filepath method to identify an .html page Date: Tue, 22 Jan 2013 16:44:17 -0500 Organization: > Bestiaria Support Staff < References: <50fe8e69$0$30003$c3e8da3$5496439d@news.astraweb.com> <0459659d-4ec2-4c7d-bee3-b4e363c916dd@googlegroups.com> <71c5445b-8100-42fb-bcfd-6b0a0886b46e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-99-200.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 87 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358891069 news.xs4all.nl 6938 [2001:888:2000:d::a6]:50211 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37352 On Tue, 22 Jan 2013 07:21:28 -0800 (PST), Ferrous Cranus declaimed the following in gmane.comp.python.general: > 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. So you want to generate a number that is used to look up another file? How many files are you referring to here? Do you mean "indicator to the actual html file" is "indicator to the COUNTER". Otherwise it is just an indicator to the same path you started with. How is this "indicator" to be used? Is it PART OF "the actual html file"? Is it a key in a database used to retrieve "the actual html file"? Pseudo-code: con = DB.connection() cur = con.cursor() cur.execute("select ID from PATHLINK where PATH = %s", thePath) data = cur.fetchone() #there should only be ONE if not data: #thePath doesn't exist, must be new file cur.execute("insert into PATHLINK (PATH) values (%s)", thePath) id = cur.lastrowid else: id = data[0] con.commit() > > Would you help me write this in python? > > Why the hell > > pin = int ( '/home/nikos/public_html/index.html' ) > > fails? because it has slashes in it? It fails because it is NOT A DECIMAL INTEGER STRING >>> int("123") 123 >>> int ("abc") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: 'abc' >>> int("abc", 16) 2748 >>> int ("abc", 12) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 12: 'abc' >>> int ("abc", 13) 1845 >>> All something you could work out by running a Python interpreter in a command shell and entering one-liner statements. E:\UserData\Wulfraed\My Documents>python ActivePython 2.7.2.5 (ActiveState Software Inc.) based on Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> int("abc", 14) 2126 >>> int("abc") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: 'abc' >>> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/