Michael Chermside wrote:
> Shankar writes:
>
>>Is there any way to convert a string into an instruction that will be
>>executed?
>
>
> Short answer:
> Yes. The exec statement does what you want:
>
>
x = 3
y = 4
exec "z = x * y"
print z
>
> 12
>
Ooh! I didn't know that on
Thank you for your help. I will post the problem in more detail if I find that
I cannot avoid using exec.
Shankar
- Original Message -
From: Michael Chermside <[EMAIL PROTECTED]>
Date: Friday, June 10, 2005 3:49 pm
Subject: RE: a question from a newcomer to this language
>
Shankar writes:
> Is there any way to convert a string into an instruction that will be
> executed?
Short answer:
Yes. The exec statement does what you want:
>>> x = 3
>>> y = 4
>>> exec "z = x * y"
>>> print z
12
HOWEVER... the long answer is that you almost certainly do NOT want
to use exe