Thread: Staff Activity
View Single Post
  #13  
Old 09-14-2012, 06:51 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
Quote:
Originally Posted by Crow View Post
Won't work, since "log" is your list of lines, not the file handle. Instead:
PHP Code:
f   open("rclog.txt",'r')
log f.readlines()
f.close() 
After a bit of research,

PHP Code:
log open('rclog.txt','r').readlines() 
Will automatic close the file descriptor (handle) once the python garbage collector finds it.

Its better to explicitly use a variable handle, or a with-block but since its a small script that will only be ran once in a while, it doesn't really matter.
For bigger projects though, you would need to close it.
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote