Is __ne__ method autogenerated?

Discussion in 'Python' started by INADA Naoki, Dec 7, 2012.

  1. INADA Naoki

    INADA Naoki Guest

    INADA Naoki, Dec 7, 2012
    #1
    1. Advertising

  2. INADA Naoki

    Ian Kelly Guest

    On Thu, Dec 6, 2012 at 11:03 PM, INADA Naoki <> wrote:
    > The reference says:
    >
    > The truth of x==y does not imply that x!=y is false.
    > Accordingly, when defining __eq__(), one should also
    > define __ne__() so that the operators will behave as expected.
    >
    > (http://docs.python.org/3/reference/datamodel.html#object.__eq__)
    >
    > But I saw different behavior on 3.3:
    > https://gist.github.com/4231096
    >
    > Could anyone teach me what happen about my code?


    http://docs.python.org/3/whatsnew/3.0.html#operators-and-special-methods

    I can't find it documented anywhere else.
    Ian Kelly, Dec 7, 2012
    #2
    1. Advertising

  3. INADA Naoki

    Chris Rebert Guest

    On Thursday, December 6, 2012, INADA Naoki wrote:

    > The reference says:
    >
    > The truth of x==y does not imply that x!=y is false.
    > Accordingly, when defining __eq__(), one should also
    > define __ne__() so that the operators will behave as expected.
    >
    > (http://docs.python.org/3/reference/datamodel.html#object.__eq__)
    >
    > But I saw different behavior on 3.3:
    > https://gist.github.com/4231096
    >
    > Could anyone teach me what happen about my code?
    >


    The reference is not completely accurate in this case. See
    http://bugs.python.org/issue4395
    "Document auto __ne__ generation; [...]"


    --
    Cheers,
    Chris
    --
    http://rebertia.com
    Chris Rebert, Dec 7, 2012
    #3
  4. INADA Naoki

    INADA Naoki Guest

    Thanks a million!


    On Fri, Dec 7, 2012 at 3:47 PM, Chris Rebert <> wrote:

    > On Thursday, December 6, 2012, INADA Naoki wrote:
    >
    >> The reference says:
    >>
    >> The truth of x==y does not imply that x!=y is false.
    >> Accordingly, when defining __eq__(), one should also
    >> define __ne__() so that the operators will behave as expected.
    >>
    >> (http://docs.python.org/3/reference/datamodel.html#object.__eq__)
    >>
    >> But I saw different behavior on 3.3:
    >> https://gist.github.com/4231096
    >>
    >> Could anyone teach me what happen about my code?
    >>

    >
    > The reference is not completely accurate in this case. See
    > http://bugs.python.org/issue4395
    > "Document auto __ne__ generation; [...]"
    >
    >
    > --
    > Cheers,
    > Chris
    > --
    > http://rebertia.com
    >




    --
    INADA Naoki <>
    INADA Naoki, Dec 7, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MS
    Replies:
    1
    Views:
    413
  2. Shane Hathaway

    __eq__ and __ne__

    Shane Hathaway, Jul 8, 2003, in forum: Python
    Replies:
    0
    Views:
    365
    Shane Hathaway
    Jul 8, 2003
  3. Tim Peters

    RE: __eq__ and __ne__

    Tim Peters, Jul 8, 2003, in forum: Python
    Replies:
    0
    Views:
    399
    Tim Peters
    Jul 8, 2003
  4. Tim Peters

    RE: __eq__ and __ne__

    Tim Peters, Jul 16, 2003, in forum: Python
    Replies:
    0
    Views:
    381
    Tim Peters
    Jul 16, 2003
  5. Robsy
    Replies:
    0
    Views:
    1,862
    Robsy
    Dec 17, 2006
Loading...

Share This Page