Skip to the content ForoHackers
Log inJoin

TypeError: '<' not supported between instances of 'dict' and 'dict'. Why is heapq judging my filling?

Data structuresDebuggingPython
#17209 · · Quote · Report

Python queue at the bakery: (1, {"loaf":"rye"}) went in fine. Next (1, {"loaf":"corn"}) and I get TypeError: '<' not supported between instances of 'dict' and 'dict'. Everything worked when I only had one kind of bread. Mum considers this evidence.

#17403 · · Quote · Report

equal first items in the tuples, so the heap tries to compare the payloads to break the tie. are you trying to promise arrival order to two customers at the same priority?

#17404 · · Quote · Report

yes. first come, first baked unless one has a different priority. if I use the loaf name as the tie breaker, baked order becomes corn then rye. our oldest customer is called Zoe and she has opposed this on constitutional grounds.

#17405 · · Quote · Report

new empty heap. push (1, 10, rye_dict) then (1, 11, corn_dict). unique increasing second field for each arrival; same priority comes back rye, corn. lower priority NUMBER still comes out first if you add (0, 12, urgent_dict).

#17406 · · Quote · Report

tried all three fresh: urgent, rye, corn. I had been poking at the old heap after the failed push like the exception guaranteed it hadn't changed. it already contained two entries. fresh queue for the test, fresh bread for Zoe.

#17411 · · Quote · Report

wtf is urgent bread

#17412 · · Quote · Report

shop's been open six minutes and that's the second time someone's asked me that. I am being investigated by Big Toast.

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply