I have a .py file with a single function that basically converts a .csv file to a .pkl file. This file, when invoked from the terminal, is supposed to convert the measurements between imperial and metrics depending on whether the input is true or not. For example
python3 file.py imperial_units=True or python3 file.py imperial_units=False and if there are no arguments provided like python3 file.py, imperial units should just default to True:
This is my attempt:
import json, sys
import pandas as pd
def log_to_pickle(units):
...
if units == True: # If units == True, convert all metric to imperial
print('Imperial True')
if imperial_unit == False:
...
elif units == False: # If units == False, convert all imperial to metric
print('Imperial False')
if imperial_unit == True:
...
...
if __name__ == "__main__":
if sys.argv == True or sys.argv == '':
log_to_pickle(True)
else:
log_to_pickle(False)
I've added the print statements inside the if/elif block to see whether my inputs work. I ran python3 file.py imperial_units=True and the output was 'Imperial False'
What am I doing wrong?