exec statement Syntax Error on string pulled from MySQL

Duncan Booth duncan.booth at invalid.invalid
Tue Apr 10 03:56:08 EDT 2007


"gregpinero at gmail.com" <gregpinero at gmail.com> wrote:

> To really get a picture of what is coming out of the DB I had the
> program print out everything about this string using this code:
>     print code
>     print repr(code)
>     print type(code)
>     for char in code:
>         print ord(char),char
> 
> To which I got:
> 
> print 'greg' print 'greg2'
> "print 'greg'\r\nprint 'greg2'"

>>> exec "1\n2"
>>> exec "1\r\n2"

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    exec "1\r\n2"
  File "<string>", line 1
    1
    
^
SyntaxError: invalid syntax
>>> 

Get rid of the carriage return.



More information about the Python-list mailing list