Saltar al contenido ForoHackers

When I print the queue my program stops feeding the customers

DepuraciónPython
#8149 · · Citar · Denunciar

I added print(list(waiting)) and it showed all three people. Then my loop over waiting served absolutely nobody. Removed the print and everybody got food. Is Python collecting a cover charge now?

I got waiting from a generator. It says "generator object" if I print it directly, which is a splendid thing to learn about three hungry people.

#8257 · · Citar · Denunciar

That first list() ate the whole generator. By the time your loop asks for a customer there's nobody left in the queue. Keep the list you just made and loop over that.

#8258 · · Citar · Denunciar

@clavo_tibio Yes. I ate the queue by reading the menu. Wonderful.

#8259 · · Citar · Denunciar

i moved the debug print inside my bread loop. if a roll has to be counted once i would like to be present when it happens

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