Saltar al contenido ForoHackers

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

Estructuras de datosDepuraciónPython
#17209 · · Citar · Denunciar

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 · · Citar · Denunciar

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 · · Citar · Denunciar

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 · · Citar · Denunciar

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 · · Citar · Denunciar

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 · · Citar · Denunciar

wtf is urgent bread

#17412 · · Citar · Denunciar

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

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder