executea string

2005-02-22 Thread Groleo Marius
I have the folowing code: c=2 e=3 s=12 code.append('funtion (c, e,s)') print \n.join(code) + '\n' The problem is when i call append. The variables s, c, e are not replaced with their value, so in the end i get the result: funtion( c, e, s); The result that i want is : funtion(2,3,12);

Re: executea string

2005-02-22 Thread Arjen Dijkstra
Groleo Marius wrote: I have the folowing code: c=2 e=3 s=12 code.append('funtion (c, e,s)') print \n.join(code) + '\n' The problem is when i call append. The variables s, c, e are not replaced with their value, so in the end i get the result: funtion( c, e, s); The result that i want is :

Re: executea string

2005-02-22 Thread Cyril BAZIN
c=2 e=3 s=12 code.append('funtion (c, e,s)') print \n.join(code) + '\n' Hello, You could try this: --- from string import Template code = c=2 e=3 s=12 code.append(Template('function ($c, $e, $s)').substitute(vars())) print \n.join(code) + '\n'