(Dec-01-2017, 07:40 PM)QueenSvetlana Wrote: , is using global variables the way I have a concern?No really,i like to do
if __name__ == '__main__':
as a natural way to see that script end.Also make it easier to test,if import code it don't automatically run.
So here is not much exposed before doing the final call.
def read_data_from_file(file_to_read): #code to read from file and build list return list_of_files def copy_files_to_backup_folder(file_to_copy): #code to copy files pass def is_backup_successful(): #code to verify that the a compressed file was created pass def write_log_file(file_name): #code to generate a log file pass def backup(file_name): files_to_backup = read_data_from_file(file_name) for f in files_to_backup: copy_files_to_backup_folder(f) is_backup_successful() write_log_file(file_name) if __name__ == '__main__': # Here do last step that start it file_name = "some/path/to/file" backup(file_name)