LONDON | 26-SDC-JUly | Boshra Mahmoudi | Sprint 4 | Implement shell tools in python - #678
Conversation
|
|
||
| for filename in args.files: | ||
|
|
||
| with open(filename) as file: |
There was a problem hiding this comment.
What happens if filename doesn't exist? You might try with error handling for FileNotFoundError.
| for filename in args.files: | ||
|
|
||
| with open(filename, "rb") as file: | ||
| content = file.read() |
There was a problem hiding this comment.
Reading the whole file with .read() is putting that data into RAM. What if you point this at a 50GB log file? Check out this code for learning a better approach here
| print(file, end=" ") | ||
| print() | ||
|
|
||
| else: |
There was a problem hiding this comment.
what happens if we try like python ls.py completely_fake_file.txt?
Your current condition checks if it's a directory but what if it is a file. Shall we just print or do something with that condition?
And what if it's neither of dir nor file? How do we handle that?
|
@Khantdotcom I have switched labels from Needs Review to Reviewed. I think you have forgotten to do this :) |
Task code
CYF-1152