Clayton Kirkwood wrote:
> Look here: After some clean-up: > if current_filename in target_directory_file_list: > current_stat_info = os.stat( > current_directory_path + '/' + current_filename, > follow_symlinks=False) > current_file_size = current_stat_info.st_size > if current_file_size == target_filename_size[current_filename]: > print( > "file", current_filename, > "size:", current_file_size, > "found in both current_directory_path", > current_directory_path, > "and", target_directory, "\n") > duplicate_files =+ 1 > else: > print("file ", current_filename, " not a duplicate\n") > As you can see the current_filename does not exist in > target_directory_file list. Yet, I fall through to the next line. Yes, the > indents are all fine: I > wouldn't have gotten to running code otherwise. Ah, the old adage "If it compiles it's done" ;) > I turned my head upside > down and still couldn't see why it doesn't work and what I am missing? I'm not completely sure what you are expecting. If you want to print file somefile.jpg not a duplicate for files not in the target_directory_file_list you need another else for the outer if > if current_filename in target_directory_file_list: > current_stat_info = os.stat( > current_directory_path + '/' + current_filename, > follow_symlinks=False) > current_file_size = current_stat_info.st_size > if current_file_size == target_filename_size[current_filename]: > print( > "file", current_filename, > "size: ", current_file_size, > "found in both current_directory_path", > current_directory_path, > "and", target_directory, "\n") > duplicate_files =+ 1 else: print("file", current_filename, "not a duplicate (different size)") else: print("file ", current_filename, "not a duplicate (not in target directory)") _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor