eval string

Thomas Jollans thomas at jollybox.de
Thu Sep 30 10:50:02 EDT 2010


On Thursday 30 September 2010, it occurred to Brandon Harris to exclaim:
>   Needing to pass a string command into a third party program and having
> issues creating a string to do what I need.
> 
> here's what I have so far.
> 
> eval('import sys;
> sys.stderr.write(\'\n\n\nCompleted!!!\nCompleted!!!\nCompleted!!!\nComplete
> d!!!\nCompleted!!!\nCompleted!!!\n\n\n\');')
> 
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "<string>", line 1
>      sys.stderr.write('

Neither ' nor " can delimit a multiline string literal. You need triplets.

>                       ^
> SyntaxError: EOL while scanning string literal
> 
> 
> so I've changed it up every way I can think and I get other errors.
> 
> eval('import sys;
> sys.stderr.write("\n\n\nCompleted!!!\nCompleted!!!\nCompleted!!!\nCompleted
> !!!\nCompleted!!!\nCompleted!!!\n\n\n");')
> 
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "<string>", line 1
>      import sys; sys.stderr.write("
>           ^
> SyntaxError: invalid syntax
> 
> 
> Brandon L. Harris



More information about the Python-list mailing list