Re: Embedding python code into text document question.

2008-01-11 Thread Thomas Troeger
Thanks guys, you've helped me very much :) Cheers & happy new year! -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding python code into text document question.

2008-01-10 Thread Erik Max Francis
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.get

Re: Embedding python code into text document question.

2008-01-10 Thread MRAB
On Jan 10, 1:10 pm, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Dear all, > > 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: $

Re: Embedding python code into text document question.

2008-01-10 Thread Marc 'BlackJack' Rintsch
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.c

Re: Embedding python code into text document question.

2008-01-10 Thread tezlo
Thomas Troeger <[EMAIL PROTECTED]> wrote: > I've written a program that parses a string or file for embedded > python commands, executes them and fills in the returned value. > ... > I've tried several solutions using eval, execfile or compile, but > none of those would solve my problem. Does anyon

Re: Embedding python code into text document question.

2008-01-10 Thread Thomas Troeger
Ok I've written a small example program to clarify matters: [SNIP] #!/usr/bin/python import os, sys, time def template(src, dst, sep): """ Copy file from src to dst, executing embedded python code. """ try: #

Re: Embedding python code into text document question.

2008-01-10 Thread grflanagan
On Jan 10, 2:10 pm, Thomas Troeger <[EMAIL PROTECTED]> wrote: > Dear all, > > 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: $

Embedding python code into text document question.

2008-01-10 Thread Thomas Troeger
Dear all, 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"