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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:47:32+00:00 2026-05-16T15:47:32+00:00

I’m still new to python, and been stuck playing around with this for a

  • 0

I’m still new to python, and been stuck playing around with this for a while and would appreciate someone pointing out where I’m going wrong.

Basically I am trying to build a list that contains a number of different objects, with each object having several attributes.

My attempt is simplified and shown below, basically I built a class for this object, containing several values, and then tried to build a list to contain the objects – it doesn’t seem to be heading anywhere successful!

Any suggestions would be greatly appreciated.

class TagData(object):
    def __init__(self):
        self.tag = []
        self.val = []
        self.rel = []
        self.database = []
        self.description = []

tagvalue='xxx'
tagList=[]
tagList.append(TagData.tag(tagvalue))
tagList.append(TagData.val(val1))

Currently I am getting an error saying TagData has no attribute ‘tag’

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-16T15:47:33+00:00Added an answer on May 16, 2026 at 3:47 pm

    First, you need to create an instance of TagData, like this:

    TagData()
    

    This is why you are getting the AttributeError, because when you use TagData.tag(…), you are really trying to call the tag method of the TagData class object, instead of setting a property of a specific instance.

    Next, you need to assign to a property or create a method to set it. For example, you could add a method like this to your class:

    def addVal(self,value):
        self.val.append(value)
    

    And then:

    a=TagData()
    a.addVal('value')
    tagList.append(a)
    

    Or you could do this (if you don’t wish to define getters/setters):

    a=TagData()
    a.val.append('text')
    tagList.append(a)
    

    Do not do all of that on one line, because when you call addVal, it will return None – and then you will append None to your list instead of your object.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.