This question is out of itch of being perfect.
I come across the case where I have to get parameter from post and check if it is True
or False
(in python), and accordingly call the LOC.
Obviously parameter read is of type <str>
and if param:
always return True
.
I had two options now,
1. Convert <str>
to <bool>
(write own code to convert, or use ast.literal_eval
or import from distutils.util import strtobool
)
2. Do the string comparison like if param == "True":
The question is what would be the best practice to follow?