Strange sorting error message

D

Dustan

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:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "[listModulePath]", line 239, in sort
self.listOfObjects.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.
 
D

Diez B. Roggisch

Dustan said:
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:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "[listModulePath]", line 239, in sort
self.listOfObjects.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
 
D

Dustan

Diez said:
Dustan said:
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.listOfObjects.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.
 
S

Steve Holden

Dustan said:
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
 
D

Dustan

Steve said:
Dustan said:
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?
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...
 
N

Neil Cerutti

Steve said:
Dustan said:
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?
 
D

Dustan

Neil said:
Steve said:
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.
 
S

Steve Holden

Dustan said:
Neil said:
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
 
F

Fredrik Lundh

Steve said:
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 <wink> tag ?

</F>
 
H

hanumizzle

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
 
D

Dennis Lee Bieber

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.
Well... If it helps, /I/ took it as a lightly sarcastic comment.
After all, the original post essentially came across as:

"I have a problem I'd like some help solving, but I'm going to
withhold certain details that might be important to finding a
resolution."

to which the response was:

"I have a solution, but I'm going to withhold certain details that
might be important to implementing it"
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top