Repository navigation
London | 26-jul-SDC | Shaghayegh far| Sprint 4 | Implement shell tools with python - #653
shaghayeghfar wants to merge 3 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
I've spotted a couple of initial issues here, can you take another look at this?
| import sys | ||
|
|
||
| # Check if the user used a flag | ||
| if len(sys.argv) > 1 and sys.argv[1] == "-n": |
There was a problem hiding this comment.
Is there a library or API you could use to handle arguments for you?
There was a problem hiding this comment.
Thank you for your feedback. I've updated my code to use Python's built-in argparse library to handle command-line arguments.
|
|
||
| # Count lines | ||
| lines = len(content.splitlines()) | ||
|
|
There was a problem hiding this comment.
Why are you leaving so much space between lines here?
|
|
||
|
|
||
| # Print the result | ||
| print(answer + filename) No newline at end of file |
There was a problem hiding this comment.
If you run this with multiple files, is there anything missing?
|
Dear @LonMcGregor |
LonMcGregor
left a comment
There was a problem hiding this comment.
A quick not about git - I saw your recent commit messages were "changes made" - it's a good idea to be a little more specific about this. Nothing to change for now, just keep in mind for the future.
The updated argparse is good. Hopefully you can see how it is helpful. You might consider updating the others in your own time if you want extra practice.
These changes look good. Just one minor extra thing to consider:
There are some repeated patterns of code in the wc.py file - do you think you could refactor to reduce this in any way?
Learners, PR Template
Self checklist
Implemented cat, ls, wc with python
Task code: CYF-1152