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 7761107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:03:41+00:00 2026-06-01T14:03:41+00:00

Consider this line in the pygame loop: pygame.display.set_mode().fill((0, 200, 255)) From: http://openbookproject.net/thinkcs/python/english3e/pygame.html I. How

  • 0

Consider this line in the pygame loop:

pygame.display.set_mode().fill((0, 200, 255))

From: http://openbookproject.net/thinkcs/python/english3e/pygame.html

I. How are you supposed to know there even is a fill function nested in set_mode? I searched in the pygame documentation and there is no information on fill in the set_mode section.

II. set_mode() is a function of the display module of the pygame package. How can I call a function nested in another function?
How could I call print"hi" with this function(tried it but get an AttributeError):

def f():
    def g():
        print "hi"
  • 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-01T14:03:41+00:00Added an answer on June 1, 2026 at 2:03 pm

    The pygame.display.set_mode() returns a Surface object.

    From the documentation:

    pygame.display.set_mode initialize a window or screen for display
    pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface

    So you are calling the method .fill() on the surface object, not on the function set_mode().

    You can find the methods available on surface objects in the surface documentation of pygame.

    You cannot call a nested function in that way.
    To get your desired result in your print example, you can use classes in the following way:

    class F():
      def g(self):
        print "hi"
    

    Resulting in:

    >>> F().g()
    hi
    

    This is a simplified example to show how the display.set_mode().fill() works:

    class Surface():
        def fill(self):
            print "filling"
    
    class Display():
        def set_mode(self):
            return Surface()
    
    
    Display().set_mode().fill()
    

    Edit:

    You can use nested functions, but it works slightly different from how you would do it with objects and modules:

    def f():
      def g():
        print "hi"
      return g
    

    Resulting in:

    >>> outerf = f()
    >>> outerf()
    hi 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using bcc32 command line compiler from Borland Embarcadero. Consider this program: int
Consider this following code (that retrieves the response from a HTTP request and prints
Consider this line: std::wcout << Hello World!; Is it OK to pass char* or
Consider this python program: import sys lc = 0 for line in open(sys.argv[1]): lc
Consider the following line: readonly private string TARGET_BTN_IMG_URL = @\\ad1-sunglim\Test\; In this line, why
Consider the following HTML string: <p>This is line 1 <br /> and this is
Consider this title for a web page: This is a mixed text from right-to-left
Consider the following PowerShell script: function Alpha { # write-output 'Uncomment this line and
Let's consider this FOR loop in a Windows batch script: D:\MiLu\Dev\C++\temp :: type string.bat
Consider this line: --dump-config=h264_sss-l2-2-ghb-16-500.ini --stats-file=h264_sss-l2-2-ghb-16-500.stat configs/example/cmp.py --l2cache -b h264_sss and this string l2-2-ghb-16. To

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.