#1
|
|||
|
|||
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? Code:
import viz viz.go() fileOutput = open(hi.txt', 'a') fileOutput.write('hi there\n') def mykeyboardfunc(key): fileOutput.flush() fileOutput.close() print "file should be closed now" viz.callback(viz.KEYBOARD_EVENT, mykeyboardfunc) |
Thread Tools | |
Display Modes | Rate This Thread |
|
|