Embedding python code into text document question.

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Thu Jan 10 09:30:19 EST 2008


On Thu, 10 Jan 2008 14:10:05 +0100, Thomas Troeger wrote:

> I've written a program that parses a string or file for embedded python 
> commands, executes them and fills in the returned value. The input might 
> look like this:
> 
> process id: $$return os.getpid()$$
> current date: $$return time.ctime()$$
> superuser: $$
> if os.geteuid():
> 	return "Yes"
> else:
> 	return "No"$$
> 
> I've tried several solutions using eval, execfile or compile, but none 
> of those would solve my problem. Does anyone have a solution that works? 
> Any suggestions? Any help will be appreciated :)

My suggestion would be:  use one of the many already existing templating
systems.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list