S
Stuchfield
Guest
Stuchfield Asks: Nested argparse if statement only returning first option
I am having an issue with a nested if else statement that reads from argparse. Here is my code:
It is my nested if/elif i'm referring to here:
currently I can only get the first if to work, even if I have set argument.chiral = 'yes' or 'y', I've tried swapping the contents of the ifs around (yes first then no) and that does not make a difference it still only executes the first if.
I'm really unsure why this does not work? If I try and
I am having an issue with a nested if else statement that reads from argparse. Here is my code:
Code:
if argument.data and argument.substructure and argument.start_date and argument.end_date:
print('Processing data. Substructure and Date filter given.')
status = True
df = pd.read_csv(argument.data)
model_dict = pipeline4(df, argument.substructure, argument.start_date, argument.end_date)
parameters = list(model_dict.keys())
if argument.chiral == 'no' or 'n':
pass
elif argument.chiral == 'yes' or 'y':
print('Getting chiral pair run down...')
path = f"{start_date}_to_{end_date}_datasets"
for param in parameters:
chiral_pairs(model_dict[param], param, path)
It is my nested if/elif i'm referring to here:
currently I can only get the first if to work, even if I have set argument.chiral = 'yes' or 'y', I've tried swapping the contents of the ifs around (yes first then no) and that does not make a difference it still only executes the first if.
I'm really unsure why this does not work? If I try and
print(argument.chiral)
I get the value I input at the commandline.