Skip to content

Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 4 | Python shell tools#331

Open
katarzynakaz wants to merge 2 commits intoCodeYourFuture:mainfrom
katarzynakaz:python-shell-tools
Open

Glasgow | 25-SDC-NOV | Katarzyna Kazimierczuk | Sprint 4 | Python shell tools#331
katarzynakaz wants to merge 2 commits intoCodeYourFuture:mainfrom
katarzynakaz:python-shell-tools

Conversation

@katarzynakaz
Copy link

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

Cat, wc and ls implemented in pyton.

@katarzynakaz katarzynakaz added 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 labels Feb 22, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Feb 22, 2026
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@katarzynakaz katarzynakaz added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. NotCoursework labels Feb 22, 2026
@OracPrime OracPrime added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Feb 28, 2026
Copy link

@OracPrime OracPrime left a comment

Choose a reason for hiding this comment

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

Some significant cleaning up needed on this one.


for file in listOfFiles:
grabbedText = Path(file).read_text(encoding="utf-8")
splitLines = grabbedText.split("\n")

Choose a reason for hiding this comment

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

There's a subtle bug here I think. Consider what happens if the file ends with a line which ends with a newline.
Or to put it another way, what does "Hello\n".split("\n") return?

flag = None
restIsFiles = args

def takeSpecifiedAction(cleanLinesArr, flag):

Choose a reason for hiding this comment

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

It's bad form, normally, to hide functions inside the top-level code of a python file. This should be before line 14.

def takeSpecifiedAction(cleanLinesArr, flag):
countingOnlyFullLines = 1

for file in cleanLinesArr:

Choose a reason for hiding this comment

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

"file" isn't a file here, it's a line. You need to rename the variable

print(f"{countingOnlyFullLines} {file}")
countingOnlyFullLines += 1
else:
print("incorrect flag")

Choose a reason for hiding this comment

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

You should validate the flag outside the loop. At the moment if the flag is invalid you'll print this message for every line of every file.


# `ls -1 sample-files`
def showVisibleInSampleFiles():
listOfFiles = os.listdir("sample-files")

Choose a reason for hiding this comment

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

Why is this path hard-coded here?


if "-a" in argv:
showAllInSampleFiles()
elif "sample-files" in argv:

Choose a reason for hiding this comment

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

No - you shouldn't be worrying about sample-files as a special case. You should take the arguments from the command line! I suspect if you look back at this file now you have more experience you'll be reaching for the keyboard!

from pathlib import Path

def calculateCounts(inputFiles):
return {

Choose a reason for hiding this comment

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

This is counting lines, words and bytes every time, which is inefficient. You should pass in a flag as to what you want, and just do a single calculation


def calculateCounts(inputFiles):
return {
"lines": len(inputFiles.split("\n")) - 1,

Choose a reason for hiding this comment

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

split("\n") has the same bug discussed in cat.py

print(f"{counts['words']} {file}")

# * `wc -c sample-files/3.txt`
def countBytes(listOfFiles):

Choose a reason for hiding this comment

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

These three functions could easily be combined into a single function with a flag.


Convert the decimal number 14 to binary.
Answer:
Answer:1110

Choose a reason for hiding this comment

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

Isn't this file left over from a different sprint? And we need .gitignore for .DS_Store

@OracPrime OracPrime 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. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Feb 28, 2026
@OracPrime
Copy link

I also don't understand why this has the "NotCoursework" tag - it's in the backlog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NotCoursework Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 4 Assigned during Sprint 4 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants