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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:12:07+00:00 2026-06-13T20:12:07+00:00

I am creating a word parsing class and I keep getting a bound method

  • 0

I am creating a word parsing class and I keep getting a

bound method Word_Parser.sort_word_list of <__main__.Word_Parser instance at 0x1037dd3b0>

error when I run this:

class Word_Parser:
    """docstring for Word_Parser"""
    def __init__(self, sentences):
        self.sentences = sentences

    def parser(self):
        self.word_list = self.sentences.split()

    def sort_word_list(self):
        self.sorted_word_list = self.word_list.sort()

    def num_words(self):
        self.num_words = len(self.word_list)

test = Word_Parser("mary had a little lamb")
test.parser()
test.sort_word_list()
test.num_words()
print test.word_list
print test.sort_word_list
print test.num_words
  • 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-13T20:12:08+00:00Added an answer on June 13, 2026 at 8:12 pm

    There’s no error here. You’re printing a function, and that’s what functions look like.

    To actually call the function, you have to put parens after that. You’re already doing that above. If you want to print the result of calling the function, just have the function return the value, and put the print there. For example:

    print test.sort_word_list()
    

    On the other hand, if you want the function to mutate the object’s state, and then print the state some other way, that’s fine too.

    Now, your code seems to work in some places, but not others; let’s look at why:

    • parser sets a variable called word_list, and you later print test.word_list, so that works.
    • sort_word_list sets a variable called sorted_word_list, and you later print test.sort_word_list—that is, the function, not the variable. So, you see the bound method. (Also, as Jon Clements points out, even if you fix this, you’re going to print None, because that’s what sort returns.)
    • num_words sets a variable called num_words, and you again print the function—but in this case, the variable has the same name as the function, meaning that you’re actually replacing the function with its output, so it works. This is probably not what you want to do, however.

    (There are cases where, at first glance, that seems like it might be a good idea—you only want to compute something once, and then access it over and over again without constantly recomputing that. But this isn’t the way to do it. Either use a @property, or use a memoization decorator.)

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

Sidebar

Related Questions

I am creating a Word class and I am getting an error: TypeError: superclass
i am creating a word (14) instance with interop out of a c# .net4
I'm running into the classic scenario where, when creating Word COM objects in .NET
Using .NET and the Word Interop I am programmatically creating a new Word doc
I am creating a custom add-in ribbon for MS Word 2010. I wanted to
I am currently in the process of creating API documentation using Microsoft Word 2007
I am creating a website with four textarea forms. Each form has a word
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
I am creating a simple word doc, using the openXml SDK. It is working
I am creating a MS Word document entirely through C# in VS 2008. I

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.