Hi everyone,i wrote a python thread that opens a file and reads it.The problem is that i dont know how to return the data as the thread will not return it from the run() method.I tried writing another function that gets the file content but when i call this function,it does nothing.What do i do please
My code
import threading, time
class LoadHtml(threading.Thread):
def __init__(self,file):
self.file=file
self.html=""
threading.Thread.__init__(self)
def run(self):
self.f=open(self.file,"r")
self.data=self.f.read()
self.f.close()
self.html=self.html+self.data
def getHTML(self):
return self.html
loadhtml=LoadHtml("testindex.ind")
loadhtml.start()
print loadhtml.getHTML()