exec considered harmful

Aquarius aquarius at kryogenix.org
Tue Jul 24 17:54:36 EDT 2001


Nick Perkins spoo'd forth:
> why exec(), when you can import?
> 
> I think that people with experience in Perl tend to want to exec() too much.
> If you have a function in another file that you want to execute, you should
> make that other file a .py file, and import it.

I exec because I've essentially defined a page type that works like MS
Active Server Pages or PHP, so I can have:

blah blah some HTML here
<?cas
some Python
?>
some more HTML

and the CGI (which is invoked as a handler for the page via an Apache
Action directive) splits the page into Python bits and HTML bits,
printing the HTML and execing the Python code. I find it a lot easier
than making each page a complete Python CGI and having to explicitly
print "" everything. It works in the same way as Poor Man's Zope, which
is another "embed Python in HTML" CGI handler.

Aq.

-- 
Well *done*, Aquarius -- a phrase we love typing because it makes us feel
like the boss-character from a 1980s Glen A Larson action series...
  NTK, http://www.ntk.net/index.cgi?backarchive99/now0618.txt&lineY2#l



More information about the Python-list mailing list