-
-
Notifications
You must be signed in to change notification settings - Fork 42
London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 4 | Implement Shell Tools-Python #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
London | 25-SDC-Nov | Zohreh Kazemianpour | Sprint 4 | Implement Shell Tools-Python #261
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start on this sprint's tasks, I have spotted a few areas where you could improve code further
| numbered_line = f"{line_number:6}\t{line}" | ||
| numbered_lines.append(numbered_line) | ||
|
|
||
| print("\n".join(numbered_lines)) # LEVEL 3: inside if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are doing the same thing in both if conditions, setting up a list of lines and then printing. Could you reduce some of the code duplication?
| files = [f for f in files if not f.startswith('.')] | ||
|
|
||
| for file in files: | ||
| print(file) No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this program without the -1 option?
| total_words += words | ||
| total_chars += chars | ||
|
|
||
| if args.lines: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test with multiple arguments given at once?
| elif args.chars: | ||
| print(f"{total_chars:8} total") | ||
| else: | ||
| print(f"{total_lines:8}{total_words:8}{total_chars:8} total") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see the repetition in the structure of the code here? Could that be reduced somehow?
Self checklist
This PR contain implementing Shell tools cat, ls, and wc commands in Python.
This was my first time working with Python! The syntax felt familiar coming from JavaScript, though I had to get used to indentation being required and some differences like
len()vs.length.