I use python 3.4 and pymysql connection to MySQL DB. I have a select query and then fetchall which returns results into r[]. r[0] is just the first part of the result tuple and its value is an empty string (as it should be based on what is in the DB.)
However, when I use the condition:
if str(r[0]) == ''.encode('utf8'):
do something...
the condition evaluates to false, instead of what I was expecting it to be true! I test it to figure out why by printing out the values of the part:
print(str(r[0]))
print(''.encode('utf8'))
print(str(r[0]) == ''.encode('utf8'))
This prints:
b''
b''
False
Any idea why? This is driving me nuts, because it should not be this hard. What am I missing?