From dcfb65028f97ed4f6482201dcc5a7429583d04be Mon Sep 17 00:00:00 2001 From: BlueNexus Date: Thu, 26 Nov 2015 14:36:43 +0000 Subject: [PATCH] More withs --- bot/NanoTrasenBot.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bot/NanoTrasenBot.py b/bot/NanoTrasenBot.py index c243f1aa0e1..a58415124fa 100644 --- a/bot/NanoTrasenBot.py +++ b/bot/NanoTrasenBot.py @@ -35,10 +35,9 @@ except ImportError: try: tiedosto = open("psycodownload.txt","r") except: - tiedosto = open("psycodownload.txt","w") - tiedosto.write("http://www.voidspace.org.uk/python/modules.shtml#psyco") - tiedosto.write("\nhttp://psyco.sourceforge.net/download.html") - tiedosto.close() + with open("psycodownload.txt","w") as tiedosto: + tiedosto.write("http://www.voidspace.org.uk/python/modules.shtml#psyco") + tiedosto.write("\nhttp://psyco.sourceforge.net/download.html") print "Check psycodownload.txt for a link" else: print "For god's sake, open psycodownload.txt" @@ -629,9 +628,8 @@ while True: arg = influx.lower()[8+len(prefix):] if debug: print truesender+":"+prefix+"suggest "+arg - tiedosto = open(targetdirectory+"suggestions/suggestions_"+str(int(time.time()))+".txt","a") - tiedosto.write(arg) - tiedosto.close() + with open(targetdirectory+"suggestions/suggestions_"+str(int(time.time()))+".txt","a") as tiedosto: + tiedosto.write(arg) conn.privmsg(targetchannel,"Suggestion received") elif cocheck( prefix+"help "): #Space in front of the ( to make sure that my command finder does not pick this up. arg = " ".join(influx.split(" ")[1:]).lower()