I'm using PyCharm and when I get an error, it prints off this neat little Traceback thing.
In this case:
Traceback (most recent call last):
File "C:/Users/Chris/PycharmProjects/Learning Project/tgrooms.py", line 127, in <module>
blueRoom()
File "C:/Users/Chris/PycharmProjects/Learning Project/tgrooms.py", line 70, in blueRoom
blueRoom()
File "C:/Users/Chris/PycharmProjects/Learning Project/tgrooms.py", line 67, in blueRoom
redRoom()
File "C:/Users/Chris/PycharmProjects/Learning Project/tgrooms.py", line 38, in redRoom
choice = int(raw_input("> "))
ValueError: invalid literal for int() with base 10: 'yes'
I know what the error is and more or less how to resolve it, but I'm wanting to make sure that the while loop isn't continuing to run when the program moves to another place.
Here is the code:
def blueRoom():
print "This is a very, very blue room. There is a door on the other side."
print "Do you walk through?"
while True:
print "inwhile"
choice = raw_input("> ")
if choice == "yes":
blueRoomComplete = True
print "You walk safely through the door into the next room."
room = random.choice(rooms)
print "%r" % room
if room == "gold_room":
print "goldroom"
gold_room()
elif room == "redRoom":
print "redroom"
redRoom()
else:
print "blueroom"
blueRoom()
break
else:
exit(0)
So here is my question: When the program goes to another function (i.e. redRoom()), is that while loop still going and taking up resources?
I did attempt to search around for a similar question, but I couldn't find anything that quite fit. Thank you all! Llurendt
Not quite sure what you're asking. When you call redRoom(), control passes to redRoom and will not return to your while loop until redRoom is done. It's not like there are multiple things running simultaneously. – BrenBarn Sep 11 '14 at 3:04
As BrenBarn stated in the comments, when redRoom() is called, nothing else from the program is currently running and resources used by the while loop are released.