I have a horrible feeling that the answer to this question is going to be obvious, but...
I am reading data from a small file in MicroPython. The value of the line I read determines whether a bool variable, debug is set or not. I have tried this two ways:
s = f.readline()
print("s = ",s)
if s == "1":
debug = True
else:
debug = False
print("debug = ",debug)
and
s = f.readline()
print("s = ",s)
debug = True if s == "1" else False
print("debug = ",debug)
In both cases, the printed output is:
s = 1
debug = False
I have also tried removing the quotes from around the 1 in case it's reading this as an integer rather than a string, but the result is the same. This is silly! What am I missing?
Is there a "\n" on the end of s perhaps, so s == "1\n"?