Strange sorting error message

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dustan

    #1

    Strange sorting error message

    I'm hiding some of the details here, because I don't want to say what
    I'm actually doing.

    I have a special-purpose class with a __cmp__ method all set up and
    ready to go for sorting. Then I have a special class that is based on
    the builtin type list (though I didn't actually inherit list; I
    probably should). When I create an instance with 2 or more items, and
    attempt to sort it, I get this strange error message:
    >>myList.sort ()
    Traceback (most recent call last):
    File "<console>" , line 1, in <module>
    File "[listModulePath]", line 239, in sort
    self.listOfObje cts.sort()
    TypeError: an integer is required

    The sort method's code is exactly what you see; it's a one-line method.

    The only thing I can think of is the __cmp__ method is returning
    something other than an integer, which it's not.

  • Diez B. Roggisch

    #2
    Re: Strange sorting error message

    Dustan schrieb:
    I'm hiding some of the details here, because I don't want to say what
    I'm actually doing.
    I have a special-purpose class with a __cmp__ method all set up and
    ready to go for sorting. Then I have a special class that is based on
    the builtin type list (though I didn't actually inherit list; I
    probably should). When I create an instance with 2 or more items, and
    attempt to sort it, I get this strange error message:
    >
    >>>myList.sort( )
    Traceback (most recent call last):
    File "<console>" , line 1, in <module>
    File "[listModulePath]", line 239, in sort
    self.listOfObje cts.sort()
    TypeError: an integer is required
    >
    The sort method's code is exactly what you see; it's a one-line method.
    >
    The only thing I can think of is the __cmp__ method is returning
    something other than an integer, which it's not.
    Does stuffing the objects in a standard list and sorting them work? How
    does the __cmp__-method look like?

    Diez

    Comment

    • Dustan

      #3
      Re: Strange sorting error message


      Diez B. Roggisch wrote:
      Dustan schrieb:
      I'm hiding some of the details here, because I don't want to say what
      I'm actually doing.
      >
      I have a special-purpose class with a __cmp__ method all set up and
      ready to go for sorting. Then I have a special class that is based on
      the builtin type list (though I didn't actually inherit list; I
      probably should). When I create an instance with 2 or more items, and
      attempt to sort it, I get this strange error message:
      >>myList.sort ()
      Traceback (most recent call last):
      File "<console>" , line 1, in <module>
      File "[listModulePath]", line 239, in sort
      self.listOfObje cts.sort()
      TypeError: an integer is required

      The sort method's code is exactly what you see; it's a one-line method.

      The only thing I can think of is the __cmp__ method is returning
      something other than an integer, which it's not.
      >
      Does stuffing the objects in a standard list and sorting them work? How
      does the __cmp__-method look like?
      Whoops, I had created the variable returnValue in __cmp__, but
      forgotten to return it. Now it works.

      That was a dumb mistake; sorry for the trouble.

      Comment

      • Steve Holden

        #4
        Re: Strange sorting error message

        Dustan wrote:
        I'm hiding some of the details here, because I don't want to say what
        I'm actually doing.
        [...]
        I have the answer to your problem but I don't actually want to tell you
        what it is.

        regards
        Steve
        --
        Steve Holden +44 150 684 7255 +1 800 494 3119
        Holden Web LLC/Ltd http://www.holdenweb.com
        Skype: holdenweb http://holdenweb.blogspot.com
        Recent Ramblings http://del.icio.us/steve.holden

        Comment

        • Dustan

          #5
          Re: Strange sorting error message


          Steve Holden wrote:
          Dustan wrote:
          I'm hiding some of the details here, because I don't want to say what
          I'm actually doing.
          [...]
          >
          I have the answer to your problem but I don't actually want to tell you
          what it is.
          That's great, seeing as I already figured out the answer, as I have
          already posted in a reply.

          Are you saying I broke one of these rules?

          Or are you just being plain rude?
          A lack of a response from you implies the latter...
          >
          regards
          Steve
          --
          Steve Holden +44 150 684 7255 +1 800 494 3119
          Holden Web LLC/Ltd http://www.holdenweb.com
          Skype: holdenweb http://holdenweb.blogspot.com
          Recent Ramblings http://del.icio.us/steve.holden

          Comment

          • Neil Cerutti

            #6
            Re: Strange sorting error message

            On 2006-10-05, Dustan <DustanGroups@g mail.comwrote:
            >
            Steve Holden wrote:
            >Dustan wrote:
            I'm hiding some of the details here, because I don't want to
            say what I'm actually doing.
            [...]
            >>
            >I have the answer to your problem but I don't actually want to
            >tell you what it is.
            >
            That's great, seeing as I already figured out the answer, as I
            have already posted in a reply.
            I had a good laugh at it.
            Are you saying I broke one of these rules?

            Or are you just being plain rude?
            A lack of a response from you implies the latter...
            SPOILER SPACE

            It was a joke, based on you hiding what you are doing, he decided
            to hide the solution to your problem. Get it?

            --
            Neil Cerutti

            Comment

            • Dustan

              #7
              Re: Strange sorting error message


              Neil Cerutti wrote:
              On 2006-10-05, Dustan <DustanGroups@g mail.comwrote:

              Steve Holden wrote:
              Dustan wrote:
              I'm hiding some of the details here, because I don't want to
              say what I'm actually doing.
              [...]
              >
              I have the answer to your problem but I don't actually want to
              tell you what it is.
              That's great, seeing as I already figured out the answer, as I
              have already posted in a reply.
              >
              I had a good laugh at it.
              >
              Are you saying I broke one of these rules?

              Or are you just being plain rude?
              A lack of a response from you implies the latter...
              >
              SPOILER SPACE
              >
              It was a joke, based on you hiding what you are doing, he decided
              to hide the solution to your problem. Get it?
              Ah, now I get it... Well, not really. I'm not outgoing, so it's hard
              for me to spot a joke when I see one.
              >
              --
              Neil Cerutti

              Comment

              • Steve Holden

                #8
                Re: Strange sorting error message

                Dustan wrote:
                Neil Cerutti wrote:
                >
                >>On 2006-10-05, Dustan <DustanGroups@g mail.comwrote:
                >>
                >>>Steve Holden wrote:
                >>>
                >>>>Dustan wrote:
                >>>>
                >>>>>I'm hiding some of the details here, because I don't want to
                >>>>>say what I'm actually doing.
                >>>>>[...]
                >>>>
                >>>>I have the answer to your problem but I don't actually want to
                >>>>tell you what it is.
                >>>
                >>>That's great, seeing as I already figured out the answer, as I
                >>>have already posted in a reply.
                >>
                >>I had a good laugh at it.
                >>
                >>
                >>>Are you saying I broke one of these rules?
                >>>http://www.catb.org/~esr/faqs/smart-questions.html
                >>>Or are you just being plain rude?
                >>>A lack of a response from you implies the latter...
                >>
                >>SPOILER SPACE
                >>
                >>It was a joke, based on you hiding what you are doing, he decided
                >>to hide the solution to your problem. Get it?
                >
                >
                Ah, now I get it... Well, not really. I'm not outgoing, so it's hard
                for me to spot a joke when I see one.
                >
                Even when it smacks you in the face, apparently. Anyway, I'm sorry if
                you thought I was getting at you in any way. Just trying to amuse the
                group ...

                regards
                Steve
                --
                Steve Holden +44 150 684 7255 +1 800 494 3119
                Holden Web LLC/Ltd http://www.holdenweb.com
                Skype: holdenweb http://holdenweb.blogspot.com
                Recent Ramblings http://del.icio.us/steve.holden

                Comment

                • Fredrik Lundh

                  #9
                  Re: Strange sorting error message

                  Steve Holden wrote:
                  Even when it smacks you in the face, apparently. Anyway, I'm sorry if
                  you thought I was getting at you in any way. Just trying to amuse the
                  group ...
                  time to reinstate mandatory use of the <winktag ?

                  </F>

                  Comment

                  • hanumizzle

                    #10
                    Re: Strange sorting error message

                    On 10/5/06, Neil Cerutti <horpner@yahoo. comwrote:
                    It was a joke, based on you hiding what you are doing, he decided
                    to hide the solution to your problem. Get it?
                    What if it was for a proprietary software of some kind?

                    -- Theerasak

                    Comment

                    • Neil Cerutti

                      #11
                      Re: Strange sorting error message

                      On 2006-10-06, hanumizzle <hanumizzle@gma il.comwrote:
                      On 10/5/06, Neil Cerutti <horpner@yahoo. comwrote:
                      >
                      >It was a joke, based on you hiding what you are doing, he decided
                      >to hide the solution to your problem. Get it?
                      >
                      What if it was for a proprietary software of some kind?
                      It wasn't sufficiently clear, hence the mild ribbing.

                      --
                      Neil Cerutti
                      The Rev. Merriwether spoke briefly, much to the delight of the
                      audience. --Church Bulletin Blooper

                      Comment

                      Working...