[Python-Dev] == on object tests identity in 3.x

Chris Angelico rosuav at gmail.com
Tue Jul 8 05:31:46 CEST 2014

On Tue, Jul 8, 2014 at 1:12 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> Why? What value (pun intended) is there in adding an explicit statement
> of value to every single class?
> "The value of a str is the str's sequence of characters."
> "The value of a list is the list's sequence of items."
> "The value of an int is the int's numeric value."
> "The value of a float is the float's numeric value, or in the case of
>  INFs and NANs, that they are an INF or NAN."
> "The value of a complex number is the ordered pair of its real and
>  imaginary components."
> "The value of a re MatchObject is the MatchObject itself."
> I don't see any benefit to forcing all classes to explicitly document
> this sort of thing. It's nearly always redundant and unnecessary.

It's important where it's not obvious. For instance, two lists with
the same items are equal, two tuples with the same items are equal,
but a list and a tuple with the same items aren't. Doesn't mean it
necessarily has to be documented, though.


More information about the Python-Dev mailing list