Hi,
I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file processed by this script,
where the concerned tmp file is only actually written to when
PythonWin is closed. In other words, after I run this script, one of
the generated tmp files has a size of 0kB. I then close PythonWin and
it is then written to.
I'm guessing the garbage collector is causing the file to be written,
but shouldn't close do this?
/Barry
import os, time, string
dir = 'c:\\temp1'
def listAllFile(fil eNames,dir,file s):
def f1(a,dir=dir): return os.path.join(di r,a)
files2 = map(f1, files)
fileNames.exten d(files2)
fileNames = []
os.path.walk(di r,listAllFile,f ileNames)
for fileName in fileNames:
fileBeginning = os.path.splitex t(fileName)[0]
fileEnd = os.path.splitex t(fileName)[1]
if fileEnd == ".py":
print fileName
f=open(fileBegi nning+".tmp", 'w')
f.write("Hello" )
f.close
I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file processed by this script,
where the concerned tmp file is only actually written to when
PythonWin is closed. In other words, after I run this script, one of
the generated tmp files has a size of 0kB. I then close PythonWin and
it is then written to.
I'm guessing the garbage collector is causing the file to be written,
but shouldn't close do this?
/Barry
import os, time, string
dir = 'c:\\temp1'
def listAllFile(fil eNames,dir,file s):
def f1(a,dir=dir): return os.path.join(di r,a)
files2 = map(f1, files)
fileNames.exten d(files2)
fileNames = []
os.path.walk(di r,listAllFile,f ileNames)
for fileName in fileNames:
fileBeginning = os.path.splitex t(fileName)[0]
fileEnd = os.path.splitex t(fileName)[1]
if fileEnd == ".py":
print fileName
f=open(fileBegi nning+".tmp", 'w')
f.write("Hello" )
f.close
Comment