Python window keep giving error message from last operation

Discussion created by garethmann on Dec 13, 2012
Latest reply on Dec 13, 2012 by garethmann
I am brand new to Python as of today. I cannot believe that ESRI is replacing VBA with full intellisense for this silly DOS window thing.

Anyway, if I run this code in the Python window in ArcMap:

def happyBirthday(person):
    print("Happy Birthday " + person + ".")


It runs fine. But then when I run this code:

import arcpy, os
def prinnames(sPath);
import arcpy, os
 folderPath = sPath
      for filename in os.listdir(folderPath):
   fullpath = os.path.join(folderPath, filename)
   if os.path.isfile(fullpath):
    basename, extension = os.path.splitext(fullpath)
    if extension.lower() == ".mxd":
     mxd = arcpy.mapping.MapDocument(fullpath)

I get this error:

Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 2)

But then, when I try to go back and paste the exact same code back into the window that ran before (The "Happy Birthday" test code), it won't run, instead it gives me the exact same error it had before (Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 2))

So why is it doing this?