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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:13:27+00:00 2026-06-06T23:13:27+00:00

class Parser(): html_escape_table = { &: &amp;, ”: &quot;, ‘: &apos;, >: &gt;, <:

  • 0
class Parser():
        html_escape_table = {
            "&": "&amp;",
            '"': "&quot;",
            "'": "&apos;",
            ">": "&gt;",
            "<": "&lt;",
            }
        def html_escape(text):
            return "".join(html_escape_table.get(c,c) for c in text)
        def query():
            database = [x, y, z, etc, etc2]
            for x in database:
                html_escape(x)
                print x #for testing purposes
                return
test = Parser()

test.query()

Am I doing this correctly? I keep getting an error:

TypeError: query() takes no arguments (1 given)

I’m not seeing anywhere where I am passing an argument to query, or even to Parser.

Can someone explain what I am doing wrong here?

I tried calling just Parser.query() and got this error (this was after adding the self argument to all of my functions and object argument to my Parser class)

    Parser.query()
TypeError: unbound method query() must be called with Parser instance as first argument (got nothing instead)
  • 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-06T23:13:30+00:00Added an answer on June 6, 2026 at 11:13 pm

    Methods in classes require the argument self this is to do with parsing the instance to the method in how python does instance methods.

    e.g.

    class Test(object):
        def say_hello(self):
            print "Hi there"
    

    Just to expand on this if you want to parse arguments to an instance method you still need self

    class Test(object):
        def say_hello(self, name):
            print "Hi %s" % name
    

    Edit:

    Okay to explain it further you have to know how python handles instances, python handles instances in a very verbose and clear way, self is always used to refer to itself or this current instance, just like this in Java. So when python calls my_instance.method() its actually calling TheObject.method(my_instance) hence why self refers to the my_instance inside the method. That allows you to use the instance inside the method with the instance itself passed around inside the arugments.

    Edit 2:

    Even when you have self as an argument to the methods you need to call it from an instance like so

    my_parser = Parser()
    my_parser.method()
    

    Edit 3:

    This isn’t Java you don’t have to bind your functions together as methods inside a class, just leave them as free-roaming functions inside a parser.py file then you can do

    import parser
    parser.do_this()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class StartAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): print "Hello" start.add_argument('-s', '--start', action=StartAction) I
I would like to write the unit test for a text parser class but
Let's say I had a class like this: class Parser attr_accessor :config, :html def
JSON Parser Class public class JSONParser { static InputStream is = null; static JSONObject
I was looking through the OpenJDK class file parser source and I came across
I have the following methods in my simple Custom Parser Class, when I execute
I'm looking for a parser that can extract methods from a java class (static
I use this class to parse a .css file. https://github.com/sabberworm/PHP-CSS-Parser I thought it's easy
In context - I'm writing a simple, standalone config file parser for a class
I am writing a parser to parse incoming text files. I have it 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.