473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question about exec()

I wrote a small webserver and a small html parser to parse some elements, in
which contain python code, now before I go any further your thinking "not
another web application server" and before being routed to Twisted, Zope,
Webware, Mod_Python, etc., this is a learning project, it is for my amusment
and better understanding. Nevertheless, inside the html document I have
python enclosed in <? ?> tags, and it executes fine, but if I have a few of
those tags I would like that prior executions stay in memory of the same
document, instead of having to load X module everytime I wish to execute the
code in the same document.

To ellaborate further:
(same document)

<some html code here>
<?
import sys
print sys.version
?>
<some more html code>
<?
print sys.platform
?>

Any help is greatly appreciated.

Adonis
Jul 18 '05 #1
1 1162
Adonis wrote:
Nevertheless, inside the html document I have
python enclosed in <? ?> tags, and it executes fine, but if I have a
few of
those tags I would like that prior executions stay in memory of the
same
document, instead of having to load X module everytime I wish to
execute the
code in the same document.


Maintain a separate globals dictionary and give it to exec:

exec code in myGlobals

--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Life is one long process of getting tired.
-- Samuel Butler
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John D. | last post by:
#This program gives: "SyntaxError: unqualified exec is not allowed # in function _ it contains a nested function with free variables" #I understand this is a scope problem(?) #I don't...
1
by: war_wheelan | last post by:
I have a TSQL script to add daily tables to replication and then run the snapshot agent to distribute them to two subscribers. The script executes without errors, but when I check the running jobs...
4
by: D. Shane Fowlkes | last post by:
I've decided to send weekly emails to registered users ("members") on one of my sites. This will be the first time I attempted anything like this. Now I know I could use some 3rd party list...
2
by: Hul Tytus | last post by:
panix.user.html, comp.infosystems.www.authoring.html question about #exec Are there any obvious errors in the html code below? All except the #exec command function as would be expected, but...
2
by: Hul Tytus | last post by:
comp.infosystems.www.authoring.html question about ssi's #exec Are there any obvious errors in the html or c code below? Without the #exec line in the html code, the text from pag1p1 and einst...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.