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

  • Home
  • SEARCH
  • 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 597493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:17:13+00:00 2026-05-13T16:17:13+00:00

Im just beginning to mess around a bit with classes; however, I am running

  • 0

Im just beginning to mess around a bit with classes; however, I am running across a problem.

class MyClass(object):
    def f(self):
        return 'hello world'
print MyClass.f

The previous script is returning <unbound method MyClass.f> instead of the intended value. How do I fix this?

  • 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-05-13T16:17:13+00:00Added an answer on May 13, 2026 at 4:17 pm

    MyClass.f refers to the function object f which is a property of MyClass. In your case, f is an instance method (has a self parameter) so its called on a particular instance. Its “unbound” because you’re referring to f without specifying a specific class, kind of like referring to a steering wheel without a car.

    You can create an instance of MyClass and call f from it like so:

    x = MyClass()
    x.f()
    

    (This specifies which instance to call f from, so you can refer to instance variables and the like.)

    You’re using f as a static method. These methods aren’t bound to a particular class, and can only reference their parameters.

    A static method would be created and used like so:

    class MyClass(object):
        def f():                 #no self parameter
            return 'hello world'
    print MyClass.f()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just beginning to have a look at Objective-C and Cocoa with a view
I am just beginning to do research into the feasibility of using Amazon's SimpleDB
I am just beginning to write an application. Part of what it needs to
I'm just beginning work with IIS, .NET, etc. so I apologize if any of
I am just beginning the move to the .NET Framework 3.5. I use CruiseControl.NET
I'm just beginning to use Regex so bear with my terminology. I have a
I'm beginning to fall in love with Extension Methods, but I just don't know
i am just beginning WPF and wonder why this works <Window ...> <Window.Resources> <Style
I'm just beginning this nice hashkell beginners tutorial: http://learnyouahaskell.com on this page on lists
I'm just beginning to teach myself MATLAB, and I'm making a 501x6 array. The

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.