Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8334523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:23:05+00:00 2026-06-09T03:23:05+00:00

I’ve been learning about Classes and I got my code to work, but I’m

  • 0

I’ve been learning about Classes and I got my code to work, but I’m just wondering where does the returned value go?

code:

from sys import exit
from random import randint

class Game(object):

    def __init__(self, start):
        self.pie = [ 'pie test']

        self.start = start

    def play(self):
        next_room_name = self.start
        while True:
            print "\n--------"
            room = getattr(self, next_room_name)
            next_room_name = room()

    def rooom(self):
        print "Test worked. good job"
        return "piez"

    def piez(self):
        print "pie room"
        exit(1)


a_game = Game("rooom")
a_game.play()

For example, in the code above I return “piez” in rooom() and it now takes me to the piez(self) function. However, where did the return value go to take me there?

Did it return “piez” outside the class and re-enter the class with the new value? Did it return the string “piez” to init(self, start) ? Did I just return the value to the previous function, play(self)?

Other than that, everything is working fine, but I just don’t understand how I arrived at the piez(self) function, simply by returning “piez” in the previous function. In the past I jumped around functions just by typing in the name of it with (), but this way I’m returning a string and not sure how I’m jumping around.

Here’s my observation:

1.) Instantiate class Game(“Rooom”) to a_game

2.) from a_game we call the play() function

3.) “Rooom” is sent to init and assigned to self.start

4.) play(self) starts and uses intialized function self.start and sets to next_room_name

5.) Loop starts. Next function is grabbed from next_room_name and assigned to room

6.) next_room_name is assigned to room() . Suddenly jump to rooom(self)

7.) We arrived at rooom(self) and return “piez”

8.) ?? Piez is returned somewhere… and we are now at piez(self)

Can someone help me fill in the gaps? It’s driving me crazy. I hope I’m making sense… I’ve just been closely trying to understand this for an hour now, and even after breaking it down I seem to be misunderstanding something.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:23:07+00:00Added an answer on June 9, 2026 at 3:23 am

    You have slight confusion here:

    5.) Loop starts. Next function is grabbed from next_room_name and assigned to room

    6.) next_room_name is assigned to room() . Suddenly jump to rooom(self)

    The return value of any statement is assigned to the left hand side of the equal sign, if the equal sign exists.

    When you write

    x = hello()

    This means:

    “Call hello and store any return value in x“

    So it should be

    “The return value of the function called by room() is stored in next_room_name“

    Hopefully this clarifies it for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.