My python program need to open (or create if they don't exist) a lot of files, so when I want to open e. g "output.txt", I just need to openfile(output.txt) to have it open. However I need to access the data once the file is open, and I would like to give it the name of the file. How do I name my var after the "name" argument here ?
def openfile(file, name):
global name
if os.path.isfile('./{0}'.format(file)):
name = open(file,"w")
else:
os.mknod(file)
name = open(file, "w")