Skip to content

Conversation

Droid-An
Copy link

@Droid-An Droid-An commented Aug 3, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Implemented shell tools in Python

Questions

what formatter to use for python?

@Droid-An Droid-An added 📅 Sprint 4 Assigned during Sprint 4 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 3, 2025
@LonMcGregor LonMcGregor added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 19, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good start on these implementations - I've left a comment on each file with a pointer to show you where you could improve them.

For your question about formatters what do you mean - formatting your code or formatting strings?

  • You can use any code formatter (or none at all), as long as you are consistent with the code you commit
  • Python has a few ways to do string formatting, the newest versions of python have something called "f-strings" that are very powerful, but might take a lot of time to learn fully

for path in args.path:
with open(path) as file:
lines = file.readlines()
line_num = 1

Choose a reason for hiding this comment

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

When printing out the line numbers, compare how the original cat application works to yours. Do you see any discrepancies?

Copy link
Author

Choose a reason for hiding this comment

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

The only discrepancies I see are in spacing. Is that acceptable, provided the output is correct?

path_proceeding(args.path)



Choose a reason for hiding this comment

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

This is a very minor remark, but try not to leave lots of blank lines throughout the file, like here at the end.

Copy link
Author

Choose a reason for hiding this comment

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

Noted, thank you

Choose a reason for hiding this comment

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

Thanks for fixing this

total.append(output.copy())
output.append(path)
string_list = map(str, output)
print(" ".join(string_list))

Choose a reason for hiding this comment

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

Can you see any problem that might happen with the displayed spacing of the output?

Copy link
Author

Choose a reason for hiding this comment

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

honestly, no

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 19, 2025
@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 20, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

  • For cat, try running the original cat program with the -nargument, with multiple files using a wildcard, and then run your own. Can you see any differences?
  • Can you see any issues with the alignment of columns if you run ẁc`with multiple files using a wildcard?

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 25, 2025
@Droid-An
Copy link
Author

Droid-An commented Sep 7, 2025

  • I saw difference in spacing, so I added more space to output. Also I aligned numbers to the right and padded with spaces on the left.
  • yes, numbers in output were not right-aligned; they were left-aligned with inconsistent spacing. I fixed it by applying rjust method before printing

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 7, 2025
Copy link

github-actions bot commented Sep 7, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

1 similar comment
Copy link

github-actions bot commented Sep 7, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

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

Good work, I think you are almost there with this implementation.

if os.path.isfile(path):
with open(path) as file:
lines = file.readlines()
line_num = 1

Choose a reason for hiding this comment

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

If I pass in multiple files the numbering still isn't quite working right here. Think about when you might want to use cat with multiple files, and why you might number the lines. How should the application behave in those cases?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, I’m not sure what part isn’t working. When I run the cat command in the console with the -n flag and multiple files, I get this output:

cyf@cyfs-MacBook-Pro cat % 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...

When I run the same with my command, I get the same result:

cyf@cyfs-MacBook-Pro cat % 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...

output_for_one_file.append(file_size)

if len(args.path) > 1:
numbers.append(output_for_one_file.copy())

Choose a reason for hiding this comment

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

Is this variable intended to help store totals? Is "numbers" a good variable name for this?

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Sep 8, 2025
Copy link

github-actions bot commented Sep 8, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

1 similar comment
Copy link

github-actions bot commented Sep 8, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Sep 12, 2025
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. 📅 Sprint 4 Assigned during Sprint 4 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants