Python's driving me mad. Invalid token?
Jim
javagrunge at hotmail.com
Fri Oct 18 02:37:17 EDT 2002
Today I installed Python 2.2.2. I wrote a short script that backs up
project files, and I'm getting a weird error that I've never gotten
before. I have spent hours trying to figure this out - can anyone
help?
My code:
import time
import os
class Elements:
def __init__(self):
self.Group = ""
self.FileList = []
def ParseFile(fname):
f = file(fname,"r")
fl = f.readlines()
for stringy in fl:
if stringy[-1] == "\n": stringy = stringy[:-1]
el = Elements()
el.Group = fl[0]
el.FileList = fl[1:]
f.close()
return el
def createBackupDir(baseName):
timeFormatString = """%m-%d-%Y %H.%M"""
timeStr = time.strftime(timeFormatString)
if baseName[-1] == "\n": baseName = baseName[:-1]
dirName = baseName + " " + timeStr
os.mkdir(dirName)
return dirName
def CopyFiles(dirname,fnamelist):
for name in fnamelist:
destFile = open((dirname+"""\"""+name),'w')
srcFile = open(name,"r")
destFile.write(srcFile.read())
srcFile.close()
destFile.close()
def MainProg():
parsed = ParseFile("test.bs")
D = createBackupDir(parsed.Group)
CopyFiles(D,parsed.FileList)
MainProg()
The error:
File "C:\***\backup.py",
line 42
MainProg()
^
SyntaxError: invalid token
Any idea at all on what this means?
Jim
More information about the Python-list
mailing list