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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:27:34+00:00 2026-05-30T01:27:34+00:00

I have this method in a class class CatList: lista = codecs.open(‘googlecat.txt’, ‘r’, encoding=’utf-8′).read()

  • 0

I have this method in a class

class CatList:

    lista = codecs.open('googlecat.txt', 'r', encoding='utf-8').read()
    soup = BeautifulSoup(lista)    
    # parse the list through BeautifulSoup
    def parseList(tag):
        if tag.name == 'ul':
            return [parseList(item)
                    for item in tag.findAll('li', recursive=False)]
        elif tag.name == 'li':
            if tag.ul is None:
                return tag.text
            else:
                return (tag.contents[0].string.strip(), parseList(tag.ul))

but when I try to call it like this:

myCL = CatList()
myList = myCL.parseList(myCL.soup.ul)

I have the following error:

parseList() takes exactly 1 argument (2 given) 

I tried to add self as an argument to the method but when I do that the error I get is the following:

global name 'parseList' is not defined 

not very clear to me how this actually works.

Any hint?

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-05-30T01:27:36+00:00Added an answer on May 30, 2026 at 1:27 am

    You forgot the self argument.

    You need to change this line:

    def parseList(tag):
    

    with:

    def parseList(self, tag):
    

    You also got a global name error, since you’re trying to access parseList without self.
    While you should to do something like:

    self.parseList(item)
    

    inside your method.

    To be specific, you need to do that in two lines of your code:

     return [self.parseList(item)
    

    and

     return (tag.contents[0].string.strip(), self.parseList(tag.ul))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method in my db class public function query($queryString) { if (!$this->_connected)
I have written this clone method for when the parent of the Employee class
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden
In my base class I have a generic method (ideally this would be a
Say I have this class Myclass that contains this method: public class MyClass {
I have this class method in a mootools class: getData : function(){ var r
I have this method in City class. It should create a new city based
If I have this method in object class: @OneToMany( fetch = FetchType.EAGER, cascade =
i have this method in my data access class and i have a unit
I have this method signature: public int nrOfEntities(Class<? extends MailConfirmation> clazz, User user, String

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.