Jul-10-2018, 10:29 PM
I'm trying to run multiple functions simultaneously:
-or so called functions because they belong to a class:
Thank you! Please tell me if something sounds obscure
-or so called functions because they belong to a class:
from sh import tail data = {} class my_Class(): def __init__(self): """Nothing to declare for initializing""" def get_data(self, filepath): """I'm trying to import the data from several files""" for line in tail("-f", "-n 1", filepath, _iter=True): data[filepath] = line print(data) my_Class().get_data("path/to/file") #call 1 my_Class().get_data("path/to/another/file") #call 2 # ... 14 similar callsI want each call to append it's data to the dictionary. And so, when I call:
my_Class().get_data("path/to/file") #call 1 my_Class().get_data("path/to/another/file") #call 2 # ... 14 similar callsThe result should print:
#1 {'filepath1' : line} #2 {'filepath1' : line, 'filepath2' : line} #3 {'filepath1' : line, 'filepath2' : line, 'filepath3' : line} # ... 13 moreAt the same time I want the content of dictionary data{...} to keep changing dynamically; because of the data in the files is flexible. For example:
#1 {'filepath1' : line} #2 {'filepath1' : last_line_in_the_file}, 'filepath2' : line} #3 {'filepath1' : last_line_in_the_file, 'filepath2' : last_line_in_the_file, 'filepath3' : line} # ... 13 moreI've already checked these posts: but it doesn't do what I ask; https://stackoverflow.com/questions/7207...n-parallel, https://stackoverflow.com/questions/2054...-in-python
Thank you! Please tell me if something sounds obscure