I am trying to compare the values of any two objects, the datatype for which could be anything (including byte array, django objects, dictionary, boolean..... and so on). Right now I am using the '==' operator for the same. Is this the correct approach of comparing two objects?
            Asked
            
        
        
            Active
            
        
            Viewed 120 times
        
    -2
            
            
        - 
                    3Did you try it? If so did it give you any reason to believe it did not work correctly? – Paul Rooney May 04 '16 at 04:07
- 
                    Well it works fine for the small pool of test cases I had, but I was wondering if there's any way to ascertain the same. – Ajay Pal Singh May 04 '16 at 04:10
1 Answers
2
            
            
        '==' returns true if two objects are equal while 'is' returns true if the two variables point to the same object. Look at this page for a more in depth explanation: Is there a difference between `==` and `is` in Python?.
Are you asking how to compare two objects that are equal in value or if they are pointing at the same common object?
 
    
    
        Community
        
- 1
- 1
 
    
    
        Chris Procak
        
- 53
- 4
