Skip to content

Instantly share code, notes, and snippets.

@mudongliang
Last active April 17, 2020 20:45
Show Gist options
  • Save mudongliang/a68280f2f19ca96311271f8839402cc7 to your computer and use it in GitHub Desktop.
Save mudongliang/a68280f2f19ca96311271f8839402cc7 to your computer and use it in GitHub Desktop.
Template for my python Script
#!/usr/bin/env python
"""
A simple python script template.
"""
from __future__ import print_function
import os
import sys
import argparse
def main(input_file):
with open(input_file, "r") as in_fd:
for line in in_fd:
print(line)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--in_file', help='provide the path of input data file', type=str)
args = parser.parse_args()
if not args.in_file:
parser.error("Please provide argument for input data file")
main(args.in_file)
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment