selectedSound=0 alarmTime=((1,2,3,4),(8,),(0,)) def printState(): print("selectedSound=",selectedSound) print("alarmTime=",alarmTime) def save(): global selectedSound lines = [] with open("Settings.py",'r') as rf: for l in rf: lines.append(l) with open("Settings.py",'w') as wf: for l in lines: if l.startswith("selectedSound"): wf.write("selectedSound="+str(selectedSound)+"\n") elif l.startswith("alarmTime"): wf.write("alarmTime="+str(alarmTime)+"\n") else: wf.write(l) #printState() #printState()