can regular ol' python do a php include?

Steve Holden steve at holdenweb.com
Tue Oct 10 11:21:53 EDT 2006


John Salerno wrote:
> Fredrik Lundh wrote:
> 
> 
>>you don't even need anything from the standard library to inserting output
>>from one function into given text...
>>
>>    text = "... my page with %(foo)s markers ..."
>>
>>    print text % dict(foo=function())
> 
> 
> Wow, thanks. So if I have a file called header.html that contains all my 
> header markup, I could just insert this line into my html file? (which I 
> suppose would become a py file)
> 
> print open('header.html').read()
> 
> Not quite as elegant as include('header.html'), but it seems like it 
> would work.

Don't overlook the fact that any *real* percent signs you want in your 
template content should be represented as a doubled percent sign: %%

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list