For inputting parameters into python you can use the getopt module. Here parameters can be optional and can be inputted in any order as long at the correct flag is present.
In the example below the user has two optional parameters to set, the input-file name and the database name. The code can be called using
python example.py -f test.txt -d HelloWorld
or
python example.py file=test.txt database=HelloWorld
or a mix and match of both.
The flags and names can be changed to reflect your needs.
import getopt
def main(argv):
inputFileName = ''
databaseName = ''
try:
opts, args = getopt.getopt(argv,"f:d:",["file=","database="])
except getopt.GetoptError:
print('-f <inputfile> -d <databasename> -c <collectionname>')
sys.exit()
for opt, arg in opts:
if opt in ('-f','--file'):
inputFileName = arg
elif opt in ('-d','--database'):
databaseName = arg
if __name__ == "__main__":
main(sys.argv[1:])