New to Python and having issues with Python seemingly executing code in the background before my print statements are executed.
I am writing a code to parse files and folders on remote file-servers.
f=[]
for key, value in remote_servers.items():
print(key + '\t' + value)
if os.path.exists(value):
deb.debug('listing: ' + value)
x = [f.name for f in os.scandir(value) if f.is_file()]
print(x)
else:
print("Cannot access '" + value + "'")
It may take several minutes or even hours to parse each remote directory within the dictionary "remote_servers".
It seems the script freezes right at the beginning, parsing the folders in the background first and then spitting out the print statements.
My goal is to know which directory currently script is processing by printing out before and after.
Is there a way to make Python respect the order and print statements before and after a function which may take hours to execute?