View Single Post
Old 10-01-2003, 05:10 PM
FlyingWren FlyingWren is offline
Join Date: Mar 2003
Location: Fargo, North Dakota, USA
Posts: 48
Closing file handles from within function

Closing file handles works fine if I don't do it from within a function call.

Consider the following, though. I press a key, and the "file should be closed now" line appears. But, the file doesn't seem to close-- it can't be renamed or deleted without first exiting the program that created it (ie, Vizard).

am I missing something?


import viz

fileOutput = open(hi.txt', 'a')
fileOutput.write('hi there\n')

def mykeyboardfunc(key):
	print "file should be closed now"
viz.callback(viz.KEYBOARD_EVENT, mykeyboardfunc)
Reply With Quote