London | 26-March-SDC | Ammad Ur Rehman | Sprint 4 | Implement shell tools (cat, ls, wc) in Python#540
Open
anosidium wants to merge 13 commits into
Open
Conversation
SlideGauge
reviewed
Jun 20, 2026
SlideGauge
left a comment
There was a problem hiding this comment.
Good job, left several comments, could you fix them please?
| continue | ||
|
|
||
| with open(path, "r") as file: | ||
| line_number = 1 |
There was a problem hiding this comment.
README requires cat -n sample-files/*.txt to behave like real cat -n, which numbers lines continuously across all files
Author
There was a problem hiding this comment.
Real cat produces:
cat -n sample-files/*.txt
1 Once upon a time...
1 There was a house made of gingerbread.
1 It looked delicious.
2 I was tempted to take a bite of it.
3 But this seemed like a bad idea...
4
5 There's more to come, though...Python cat produces:
python3 cat.py -n sample-files/*.txt
1 Once upon a time...
1 There was a house made of gingerbread.
1 It looked delicious.
2 I was tempted to take a bite of it.
3 But this seemed like a bad idea...
4
5 There's more to come, though...The only difference is the indentation.
|
|
||
| args = parser.parse_args() | ||
|
|
||
| entries = os.listdir(args.filepath) |
There was a problem hiding this comment.
Does os.listdir return dir list in an alphabetical order? Compare with what real ls does
Author
There was a problem hiding this comment.
When I run ls -a, it produces:
. ls.py README.md
.. node_modules sample-filesWhen I run the Python variant, python3 ls.py -a:
. .. README.md ls.py node_modules sample-filesThe alphabetically ordering does not match.
Author
|
Thanks for the review. I've made some changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Reimplement the shell programs as a Python program.