Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 4 | Implement shell tools in python#497
Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 4 | Implement shell tools in python#497enjoy15 wants to merge 9 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start, but there is some work left to do here.
Is there a package you could use to help with managing arguments? Right now it is a bit complex, and you can't combine single-letter arguments like the command line tools.
LonMcGregor
left a comment
There was a problem hiding this comment.
Good work switching to using the argparse library. I do have some questions, as it looks like you are maybe not using the library as effectively as you could be.
|
Thanks for replying @enjoy15 - Could you try implementing the ls using the standard argparse without subclassing or adding custom functions? It would help to reduce the amount of code that you have written, making it more readable and maintainable |
|
@LonMcGregor Suggestion implemented. Thank you! |
LonMcGregor
left a comment
There was a problem hiding this comment.
Great, this looks a lot cleaner now. One question, see my comment
LonMcGregor
left a comment
There was a problem hiding this comment.
The -1 is no longer required, but I think you still need to think about how the -1 argument works, see my comment
|
|
||
| locale.setlocale(locale.LC_COLLATE, "") | ||
| for entry in sorted(entries, key=locale.strxfrm): | ||
| print(entry) |
There was a problem hiding this comment.
Think about the purpose of the -1 argument. How should the output differ when it is activated and when it is not? Does your implementation meet that expectation?
There was a problem hiding this comment.
Thank you for the catch! I realized that my original implementation was always printing one item per line, meaning the -1 flag wasn't actually changing the behavior.
I have updated the code so that it now checks for the one_per_line argument. If it's active, it prints one entry per line; otherwise, it outputs the entries horizontally, separated by spaces, to mimic the default ls behavior.
LonMcGregor
left a comment
There was a problem hiding this comment.
Thanks, this ls implementation matches the spec now. well done
Thank you! |
Learners, PR Template
Self checklist
Changelist
Completed all exercises