Skip to the content ForoHackers
Log inJoin

When I print the queue my program stops feeding the customers

DebuggingPython
#8149 · · Quote · Report

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 · · Quote · Report

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 · · Quote · Report

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

#8259 · · Quote · Report

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

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