<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3105.105" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV>The first line in the string is indented, which is a syntax error.
The<BR>first line of the string has to be non-indented.</DIV>
<DIV> </DIV>
<DIV>"eric wilson" wrote:</DIV>> hi -<BR>> i am new to python and i'm
trying to use the compile / exec feature for<BR>> speeding up a loop.
i'm using python v2.0 with pythonwin. i don't<BR>> understand why this
doesn't work....<BR>> thanks in advance for the help.<BR>> <A
href="file://eric">file://eric</A><BR>> <BR>> the code snippet looks like
this:<BR>> exec_code = compile("""<BR>>
for eachLine in map(strip, allLines):<BR>>
mySequence = split('\s\s+|\t',
eachLine)<BR>> foundFields =
str(gm2local(DateTimeFromString(mySequence[0])))[:-3]<BR>> + '\t' +
mySequence[1]+ '\t' + mySequence[4]+ '\t' + mySequence[5]+ '\t' +<BR>>
mySequence[9]+ '\t' + mySequence[16] + '\n'<BR>>
fw.write(foundFields)<BR>>
count = count + 1<BR>>
""", '', 'exec')<BR>> exec
exec_code<BR>> <BR>> the error message that i get when this piece of code
runs is:<BR>> Traceback (most recent call last):<BR>> File
"C:\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in<BR>>
RunScript<BR>> exec codeObject in
__main__.__dict__<BR>> File "E:\W2\pytest\logman.py", line 114, in
?<BR>> checkArgs()<BR>> File
"E:\W2\pytest\logman.py", line 110, in checkArgs<BR>>
parmFind(sys.argv[1], sys.argv[2])<BR>> File "E:\W2\pytest\logman.py",
line 55, in parmFindRAM<BR>> exec_code =
compile("""<BR>> File "<string>", line 2<BR>>
for eachLine in map(strip, allLines):<BR>>
^<BR>> SyntaxError: invalid
syntax<BR></FONT></DIV></BODY></HTML>