template

Carl Banks imbosol at vt.edu
Sun Aug 11 22:20:31 CEST 2002


William Dode wrote:
> hi,
> 
> I'm doing a system to embed python code in html page. (like pyhp and pmz, but with an other aproach...)
> 
> I don't know what could be the best for balises.
> 
> <py>
> ...
> </py>
> <!--py
> ...
> -->
> <?py
> ...
> ?>
> 
> Any suggestions ?


In my system, I use <python>...</python>.  This has the advantage of
having the same syntax as HTML, so you want to use this if you're
using SGML tools (or perverted SGML tools like sgmllib) to process
this file.

<!--py ... --> appears to be for systems that will stick occasional
dynamic content into a mostly static web page.  The idea is that it's
supposed to be an SGML comment (even though it isn't necessarily) and,
if somehow your page gets served without the substitution, the web
browser (hopefully) ignores it and you still have something that looks
like an HTML file.  This is probably the best way (of your three
choices) to do it if you're using regular expressions to find they
embedded scripts.

<?py ... > I don't know, maybe the idea here to take up very few
bytes.  I would only consider doing it this way if I were scanning the
file line-by-line, looking for the embedded scripts.


The point is, which one you use depends a lot on how you're finding
and replacing the embedded scripts.


-- 
CARL BANKS
http://www.aerojockey.com



More information about the Python-list mailing list