Reputation: 777
I am coding an module using redis-py, here I have a problem :
def get_users_from_usergroup(usergroup):
get_result = r_server.hmget('usergroups', usergroup)
if get_result is not None:
print('users from the given usegroup [' + usergroup + '] are :')
print(get_result)
return (get_result)
else:
print("Usergroup not found")
return "error"
I make a check on None values but it doesn't work I never enter in the else loop, even though the result is None. Output :
users from the given usegroup [random] are :
[None]
users from the given usegroup [random] are :
[None]
users from the given usegroup [random] are :
['as872 bs940 e0286']
I have probably missed something but I don't know what.
Upvotes: 0
Views: 1240
Reputation: 23098
>>> [None] is None
False
is the answer to your question. Try to change your condition to:
if get_result[0]:
# there are results
else:
# there are no results
Upvotes: 1