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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:58:52+00:00 2026-06-13T02:58:52+00:00

This is my code so far: class Compound(Item): def __init__(self, itemID, name, products, itemlist):

  • 0

This is my code so far:

class Compound(Item):

    def __init__(self, itemID, name, products, itemlist):
        Item.__init__(self,itemID,name)
        self._products = products
        self._items_list = itemlist


    def get_cost(self):
        return self._cost

    def get_items_list(self):
        return self._items_list

    def get_items_str(self):
        return "".format(self._itemID, self._name)

    def set_items(self, itemlist):
        self._itemlist= itemlist

    def get_depend(self):
        allitems = []
        for a in self._set_items:
            allitems.append(n[0])
            return allitems

    def __repr__(self):
        return "{0}, {1}, {2}".format(self._itemID, self._name, self._products, self._items_list)

    def __str__(self):
        return '{0}     {1}                            {2}'.format(self._itemID, self._name, self._products, self._item_list)

class Products():
   def __init__(self):
        self._products = {}

   def get_item(self, itemID):
        return self._products.get(itemID)

    def add_item(self, itemID, product):
        self._products[itemID] = product

    def remove_item(self, itemID, product):
        if item in products:
            self._products.remove(item)
            return True
        return False

    def delete_all(self):
        self._products.clear()

    def get_keys(self):
        return self._products.keys()

    def check_depend(self, item):
        for i in self._products:
            depend = self._products(i).get_depend()
            if item in depend:
                return True
            return False

When I run the following code:

products.add_item('CWH111', Compound('CWH111', 'Mountain Bike Built Wheel', products, [('TR202', 1), ('TU227', 1), ('WH239', 1)]))
products.get_item('CWH111')

I want to get

CWH111, Mountain Bike Built Wheel, TR202:1,TU227:1,WH239:1

but instead, all i get is

CWH111, Mountain Bike Built Wheel, <____main____.Products instance at 0x0000000002727588>

I have tried a lot of different things; can some one please tell me what I am doing wrong?

  • 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-13T02:58:53+00:00Added an answer on June 13, 2026 at 2:58 am

    You are not using specifying a string formatter the self._items_list argument here:

    return "{0}, {1}, {2}".format(self._itemID, self._name, self._products, self._items_list)
    

    You only have 3 slots there ({0}, {1} and {2}), but you pass in 4 arguments. The following would already be better:

    return "{0}, {1}, {2}".format(self._itemID, self._name, self._items_list)
    

    even though that would not print exactly what you wanted.

    You want to format self._items_list a bit more:

    il = ','.join(['{0}:{1}'.format(*item) for item in self._items_list])
    return "{0}, {1}, {2}".format(self._itemID, self._name, il)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey im having this code so far - (id)initWithDictionary:(NSDictionary *)aDictionary { self = [super
I have this code so far: private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
I have this code so far which perfectly but relies on there being a
This is my code thus far: ArrayList<String> matches = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String playString =
This is my code so far: var n = 123456789; var d = n.toString().length;
SO this is my code so far: JS: <script type=text/javascript> function Hide(srcField) { var
As far as I can tell, this code is fine, and should display some
This is really confusing me. I will show my code so far. I am
This is what I have as far as code, it is in the first
Learning some VBA. So far, I've constructed this piece of code which should allow

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.