Skip to content

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
CodeYourFuture:mainfrom
anosidium:implement-shell-tools-in-python
Open

London | 26-March-SDC | Ammad Ur Rehman | Sprint 4 | Implement shell tools (cat, ls, wc) in Python#540
anosidium wants to merge 13 commits into
CodeYourFuture:mainfrom
anosidium:implement-shell-tools-in-python

Conversation

@anosidium

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Reimplement the shell programs as a Python program.

@anosidium anosidium added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jun 15, 2026
@SlideGauge SlideGauge added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jun 20, 2026

@SlideGauge SlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, left several comments, could you fix them please?

Comment thread implement-shell-tools/cat/cat.py Outdated
continue

with open(path, "r") as file:
line_number = 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README requires cat -n sample-files/*.txt to behave like real cat -n, which numbers lines continuously across all files

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread implement-shell-tools/cat/cat.py Outdated
Comment thread implement-shell-tools/cat/cat.py Outdated
Comment thread implement-shell-tools/ls/ls.py Outdated

args = parser.parse_args()

entries = os.listdir(args.filepath)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does os.listdir return dir list in an alphabetical order? Compare with what real ls does

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run ls -a, it produces:

.               ls.py           README.md
..              node_modules    sample-files

When I run the Python variant, python3 ls.py -a:

.       ..      README.md       ls.py   node_modules    sample-files

The alphabetically ordering does not match.

Comment thread implement-shell-tools/ls/ls.py
@anosidium

Copy link
Copy Markdown
Author

Thanks for the review. I've made some changes.

@anosidium anosidium removed the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants