Using filepath method to identify an .html page

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Jan 22 06:31:11 EST 2013


On Tue, 22 Jan 2013 02:07:54 -0800, Ferrous Cranus wrote:

> Hello, i decided to switch from embedding string into .html to actually
> grab the filepath in order to identify it:

What do you think "the filepath" means, and how do you think you would 
grab it?

I can only guess you mean the full path to the file, like:

/home/steve/mypage.html

C:\My Documents\mypage.html


Is that what you mean?


> # open current html template and get the page ID number
> f = open( page )
> # read first line of the file
> firstline = f.readline()
> # find the ID of the file and store it 
> pin = re.match( r'<!-- (\d+) -->', firstline ).group(1) 
>
> This is what i used to have.
> 
> Now, can you pleas help me write the switch to filepath identifier? I'am
> having trouble writing it.

I don't understand the question.


-- 
Steven



More information about the Python-list mailing list