Skip to content

Instantly share code, notes, and snippets.

@seekshreyas
Last active December 19, 2015 11:19
Show Gist options
  • Select an option

  • Save seekshreyas/5947254 to your computer and use it in GitHub Desktop.

Select an option

Save seekshreyas/5947254 to your computer and use it in GitHub Desktop.
Scaffolding for my Python programs
#! /usr/bin/python
""" Program Aim
More description about the program
"""
__author__ = "@Name"
__email__ = "@Email"
__python_version = "Python 2.7.3 -- EPD 7.3-2 (32-bit)"
from optparse import OptionParser
def getInput():
parser = OptionParser()
parser.add_option('-d', '--dir', dest='dirpath')
parser.add_option('-t', '--type', dest='filetype', default='xml')
(option, args) = parser.parse_args()
if not option.dirpath:
return parser.error('directory path not given. User --dir="path.to.directory" for file statistics')
return {'dir': option.dirpath, 'type': option.filetype}
def main():
userInput = getInput()
print userInput['dir'], userInput['type']
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment