summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/cat.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/cat.py b/python/cat.py
new file mode 100644
index 0000000..d93ba65
--- /dev/null
+++ b/python/cat.py
@@ -0,0 +1,13 @@
+import argparse
+
+# Create an argument parser to obtain file name
+parser = argparse.ArgumentParser(description='cat')
+parser.add_argument('-f', '--file', help='File name')
+args = parser.parse_args()
+
+# Open the file using the `file` argument
+path = args.file
+with open(path, 'r') as file:
+ # Read and print the file contents
+ contents = file.read()
+ print(contents)