Python Webpages

François Pinard pinard at iro.umontreal.ca
Mon Apr 29 13:45:30 EDT 2002


[Jon Ribbens]

> [...] I do not think that code of any sort should be in the HTML
> pages. Code and HTML are separate things that belong in separate files
> rather than muddled together.

I presume this is debatable.  Up to now, I found easier having single files,
for the case you are adjusting both aspects in a single editing session.

This is a bit like if a programming language was forcing comments in a
file and code in another.  It is more easy editing comments and the code
together.  Or course, we have separate manuals for bigger things -- but I
like to think that active HTML pages are like very small projects, edited as
needed by both by the HTML designer (who is not necessarily a programmer)
and the application programmer (who is not necessarily an HTML designer).
Yet, seeing the whole thing, both the designer and the programmer can leave
the page in a consistent state, even if not fluent in the _other_ field.

The same applies for `awk' or `yacc' which mixes patterns or grammars with
actions related to them.  And for all kind of literate programming.

> Linking web pages with installed Python modules is exactly what jonpy does.
> [...] Yes, it is my belief that jonpy, while being very simple, is also
> very powerful.

Good! :-) I felt a need for simplicity, leaving the bulk of the power to
Python itself.  My experience taught me that it is attractively simple to
use a single file instead of two, for linking HTML and Python into active
pages.  Of course, if we have lengths of Python code, these are best kept
in separate (and compiled) modules, merely imported from the HTML page.
For better style, and a bit for better speed, the amount of Python code
in HTML pages should stay small.

> Hence my question to Paul about what features of other more complicated
> templating systems make him feel that they have "extra power" in
> comparison, because personally I can't think of any.

PHP is a clear example of bloat.  There are others!  PHP has a lot of things,
and is a little monstrous to learn fully.  I agree with you that the extra
power is not worth all the time it takes for one to study the tool, and
easily defeated with only a few lines of Python, here and there, as needed.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list