I have
fruits = [apple, banana, pineapple, oranges]
sizes = [small, medium, large]
My code generates files for fruitproperty for each of the fruit-size combination. I am trying to do this two ways: (1) Code will compile for all fruit-size combinations (2) Code will compile for only specified fruit and it's three combinations.
I require maindir as compulsory argument while fruit name is optional argument
Following is my code:
parser = argparse.ArgumentParser(description = " require maindir path and if required fruit name for single compilation")
parser.add_argument('maindir', help = 'Give maindir path', action = 'store')
parser.add_argument("-p","--fruit",help = "Please give fruit name", type=str, default = "apple, banana, pineapple, oranges")
args = parser.parse_args()
print args
fruit =[str(item) for item in args.fruit.split(',')]
sys.argv[1]= os.environ.get(sys.argv[1],sys.argv[1])
def compile()
# Code for creating files for fruitproperty for the given fruit-size combination.
Then I call the function as below:
if sys.argv[3] == fruit:
for size in sizes
compile()
else:
for fruit in fruits
for size in sizes
compile()
so even if I give optional argument, my code is by default compiling for all fruit-size combinations instead of the given specific fruit-size combinations. Where am I getting it wrong?
help = "Please give fruit name'- quotes are misbalanced, is this present in your original code?