Reputation: 1140
class Downloader(threading.Thread):
def __init__(self, priority_level, output_function):
self.IDs = self.load_IDs(priority_level)
self.sleep_interval = self.gen_sleep(priority_level)
self.output = output_function
self.name = '[Downloader::%s]'%(str(priority_level))
self.output('[Downloader] New downloader created (prio: %s)!'%(str(priority_level))
def load_IDs(self, prio):
filename = 'id_prio%s.data'%str(prio)
ID_file = open(filename, 'r')
ID_data = ID_file.read()
ID_file.close()
temp = open(filename, 'w')
temp.write('\n')
temp.close()
IDs = [line.split(':') for line in ID_data.split('\n') if ID != '']
return IDs
[MORE CODE...]
For some reason, I get the following error:
File "pastebin_rip_2.py", line 40
def load_IDs(self, prio):
^
SyntaxError: invalid syntax
What am I doing wrong? for a moment I considered the issue might have been the placing of init, because when I moved it to the end of the Downloader class it worked fine (which doesn't make sense?). Well, Downloader did, anyway. Instead I got a message complaining about the class after Downloader.
I really don't see what's wrong. Help?
(Entire code: http://snipt.org/xkky)
Upvotes: 0
Views: 445
Reputation: 3093
I think you're missing a closing paren at this line:
self.output('[Downloader] New downloader created (prio: %s)!'%(str(priority_level))
Upvotes: 4