Jul-10-2018, 10:29 PM
I'm trying to run multiple functions simultaneously:
-or so called functions because they belong to a class:
I want each call to append it's data to the dictionary. And so, when I call:
The result should print:
At 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:
I'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
-or so called functions because they belong to a class:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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 calls |
1 2 3 |
my_Class().get_data( "path/to/file" ) #call 1 my_Class().get_data( "path/to/another/file" ) #call 2 # ... 14 similar calls |
1 2 3 4 |
#1 {'filepath1' : line} #2 {'filepath1' : line, 'filepath2' : line} #3 {'filepath1' : line, 'filepath2' : line, 'filepath3' : line} # ... 13 more |
1 2 3 4 |
#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 more |
Thank you! Please tell me if something sounds obscure