Why won't exec accept this?
Gene
gchiaramonte at mail.com
Wed Jun 28 15:46:57 EDT 2000
I am trying to store scripts in a dictionary, then exec the scripts as
necessary. I have stored the following text in a dictionary:
# test ...
def FooBar(x):
return x + x
# here is the dictionary...
{'script': '# test ...\015\012def FooBar(x):\015\012 return x + x',
'version': 1.0, 'type': 'script'}
# and here is what happens...
>>> print d['script']
# test ...
def FooBar(x):
return x + x
>>> exec d['script']
Traceback (innermost last):
File "<interactive input>", line 1, in ?
File "<string>", line 2
def FooBar(x):
^
SyntaxError: invalid syntax
If anyone can tell what is wrong, I would appreciate any help you could give
me.
Thanks,
Gene
More information about the Python-list
mailing list