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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:49:42+00:00 2026-06-18T14:49:42+00:00

I am trying to simply get the value out of my class using a

  • 0

I am trying to simply get the value out of my class using a simple function with a return value, I’m sure its a trivial error, but im pretty new to python

I have a simply class set up like this:

class score():
#initialize the score info 
    def __init__(self):
        self.score = 0
        self.num_enemies = 5
        self.num_lives = 3

    # Score Info
    def setScore(num):
        self.score = num

    # Enemy Info
    def getEnemies():
        return self.num_enemies

    # Lives Info
    def getLives():
        return self.getLives

etc.....

Than I create an instance of the class as such:

scoreObj = score()

for enemies in range(0, scoreObj.getEnemies):
    enemy_sprite.add(enemy())  

I get the error saying that an integer is expected, but it got an instancemethod

What is the correct way to get this information?

Thanks!

  • 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-18T14:49:44+00:00Added an answer on June 18, 2026 at 2:49 pm

    The first parameter for a member function in python is a reference back to the Object.

    Traditionally you call it “self”, but no matter what you call the first parameter, it refers back to the “self” object:

    Anytime I get weird errors about the type of a parameter in python, I check to see if I forgot the self param. Been bit by this bug a few times.

    class score():
    #initialize the score info 
        def __init__(self):
            self.score = 0
            self.num_enemies = 5
            self.num_lives = 3
    
        # Score Info
        def setScore(self, num):
            self.score = num
    
        # Enemy Info
        def getEnemies(self):
            return self.num_enemies
    
        # Lives Info
        def getLives(foo): #foo is still the same object as self!!
            return foo.num_lives
            #Works but don't do this because it is confusing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get value from passwordbox for developing a simple login functionality,
I am trying to get comp1's value in the most simple way in C#.
I am trying to find simple, elegant way to get all the pertinent name,value
I'm trying to get a fairly simple script which persists a value and retrieves
I'm just trying to get a simple example of accessing a custom java class
I am trying to do a simple application using Ajax and servlet. But when
Sure I'm missing something simple here. I'm trying to assign a value to a
I'm trying to get my models related using ReferenceProperty, but not have a huge
I'm trying to use a simple HTTP get to load a string from a
i'm fairly new to django and just trying a couple simple experiments to get

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.