Skip to content

Instantly share code, notes, and snippets.

@steveoh steveoh/args.py

Created Apr 3, 2017
Embed
What would you like to do?
get command line args
#!/usr/bin/env python
# * coding: utf8 *
'''
args.py
A module that contains sample code to get params
'''
import sys
if len(sys.argv) > 1: #: run `args.py a b` in the command line
#: args were passed to the script get the values
param1 = sys.argv[1] #: a
param2 = sys.argv[2] #: b
else: #: run `args.py` in the command line
param1 = raw_input('type something and hit enter to get a value: ')
param2 = raw_input('type something and hit enter to get b value: ')
print('first value is {}'.format(param1))
print('second value is {}'.format(param2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.