[Tutor] Why not to use include?

Dotan Cohen dotancohen at gmail.com
Mon Jun 9 17:54:06 CEST 2008

2008/6/9 W W <srilyk at gmail.com>:
> Python can *too* import from a txt file (even if it contains HTML):
> f = open("myfile.html", "r")
> x = f.read()
> print x
> f.close()
> It even retains formatting (as far as I can tell)...
> HTH,
> Wayne

Thanks, Wayne, I am actually aware of this method. But it seems that
what I really want _is_ a function, and not a simple include. The
header prints, among other things, the page title which I pass to the
include as a simple variable in PHP. I never realized how broken of a
design that is until now. One thing I've just learned: the arguments
that PHP encourages bad programming are true (not to knock the
language, which I happen to enjoy).

I must learn about these things, I've discovered, in this order:
1) How to use Python as an apache module, not as cgi. Each page, at
least to the outside world, must have an .html extension.
2) I must learn about classes, and how to include classes in specific pages.
3) How to access GET, POST, and environmental values in Python. By
environmental values I mean the requesting page's IP address, UA
details such as preferred language and charset (which I use to serve
the homepage in one of two languages), the query string, etc.
4) How to access and work with MySQL. I am familiar with SQL, it is
just the python integration I need to learn (how to send a query, how
to parse the reply).
5) How to work with cookies in Python.
6) How to send mail with Python and sendmail.
7) How to manipulate images with Python. From what I understand this
is _not_ possible, so I may have to stick with php on this one.


Dotan Cohen


A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

More information about the Tutor mailing list