Skip to content

Commit de994f8

Browse files
Merge pull request #1489 from BBarbuz/master
Modifed 'cat' Program to work without commas and made code more clear
2 parents f3b1dc5 + bdc876b commit de994f8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Cat/cat.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
utility. Compatible with Python 3.6 or higher.
1515
1616
Syntax:
17-
python3 cat.py [filename1,filename2,etcetera]
18-
Separate filenames with commas and not spaces!
17+
python3 cat.py [filename1 filename2 etcetera]
18+
Separate filenames with spaces as usual.
1919
2020
David Costell (DontEatThemCookies on GitHub)
2121
v1 - 02/06/2022
2222
"""
2323
import sys
2424

25+
2526
def with_files(files):
2627
"""Executes when file(s) is/are specified."""
2728
file_contents = []
@@ -38,6 +39,7 @@ def with_files(files):
3839
for contents in file_contents:
3940
sys.stdout.write(contents)
4041

42+
4143
def no_files():
4244
"""Executes when no file(s) is/are specified."""
4345
try:
@@ -51,13 +53,16 @@ def no_files():
5153
except EOFError:
5254
exit()
5355

56+
5457
def main():
5558
"""Entry point of the cat program."""
5659
try:
5760
# Read the arguments passed to the program
58-
with_files(sys.argv[1].strip().split(","))
61+
file = sys.argv[1:]
62+
with_files(file)
5963
except IndexError:
6064
no_files()
6165

66+
6267
if __name__ == "__main__":
6368
main()

0 commit comments

Comments
 (0)