Version 1 - #1
Conversation
| input_file.write(new_data) | ||
| input_file.close() | ||
| return |
There was a problem hiding this comment.
Doesn't any functions should retrurn?
| import sys | ||
| import os | ||
| PATH = 1 |
There was a problem hiding this comment.
Don't need that.
Don't use consts on 1 use only
There was a problem hiding this comment.
I ommited the PATH, I beieve the import is ok
| directory = sys.argv[PATH] | ||
| if ".txt" in directory: | ||
| pass | ||
| else: | ||
| print(os.listdir(directory)) | ||
| file_name = input("Enter file name from list above: ") | ||
| directory += "\\" + file_name |
There was a problem hiding this comment.
Nice Feature but not needed, you can safely assume you get a valid file name
There was a problem hiding this comment.
O.k. I think it's fine to leave it. If you would like I will ommit it.
| file_name = input("Enter file name from list above: ") | ||
| directory += "\\" + file_name | ||
| except Exception as error_message: |
There was a problem hiding this comment.
Way too wide of an exception - if you try to catch one - use the specific one or the class exception
| print(error_message) | ||
| directory = input("Enter the file's directory you want to work with:") | ||
| input_file = open_file(directory, 'r') |
There was a problem hiding this comment.
Extra something - read about "with open()" and context managers in general - makes the code way more readable
| except: | ||
| print("Error") |
There was a problem hiding this comment.
That's not better, find a specific exception that you want to catch
No description provided.