Membership comparsion in python
Question: I am not sure whether i am doing it correctly but please consider the below
code. a and b values are same (i.e "John") but when doing a membership test
(i.e a in b) then it says false. But when checking the value equality then it
shows True but somehow membership test is saying false even though the values
are same.

    
    
    >>> import redis
    >>> r.mset(first="John", second="Stanley", third="Junior")
    >>> a = r.mget(["first"])
    >>> a
    ['John']
    >>> b = r.mget(["first"])
    >>> b
    ['John']
    >>> a in b
    False
    >>> a == b
    True
    


Answer: You can check below console result.

    
    
    >>> ['John'] in ['John'] # list in list
    False
    >>> ['John'] in [['John']] # list in double list
    True
    >>> 'John' in ['John'] # Probably this is what you want.
    True
    >>> ['John'] == ['John']
    True
    >>> 'John' == ['John'] # 'John' is an element in List ['John'] but not same.
    False
    

And redis support 'exsits' keyword.

    
    
    >>> r.exists('John')
    True
    >>> r.exists('foo')
    False
    

