In the future, you might want to look at using the cPickle module for storing objects (lists, numbers, dictionaries, pretty much anything) in a text file and retrieving the same objects later on.
Here is an example where the rotation of the mainview of Vizard is stored in a text file (by pressing the d-key) and read from that file (by pressing the r-key):
Code:
import viz
import cPickle
viz.go()
def writeInfo():
orientation = viz.MainView.getEuler()
file_rot = open('MainView_rot.txt', 'w+')
cPickle.dump(orientation, file_rot)
file_rot.flush()
file_rot.close()
print 'Succesfully pickled:', orientation
def readInfo():
try:
file_rot = open('MainView_rot.txt', 'r')
orientation = cPickle.load(file_rot)
file_rot.flush()
file_rot.close()
print 'Succesfully unpickled:', orientation
except IOError:
print 'Could not read file!'
def onKeyDown(key):
if key in 'dD':
writeInfo()
elif key in 'rR':
readInfo()
else:
pass
viz.callback(viz.KEYDOWN_EVENT, onKeyDown)