cmc/learn
My personal learning area.
clone: git clone https://gitbay.org/cmc/learn.git
3fed2f0b637ca18343fb0082e44532d470c1b61f
verified · cmc
author: Christian Cleberg <hello@cleberg.net> · 2025-05-20T19:37:37Z
.gitignore | 1 + python/cat.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) new file mode 100644 @@ -0,0 +1 @@ +python/venv \ No newline at end of file new file mode 100644 @@ -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)