Veneer - TypeError: object() takes no parameters

I get the following error and not really sure why

Traceback (most recent call last):
  File "script.py", line 70, in <module>
    edytta.sell_artwork(picasso, "$6M (USD)")
  File "script.py", line 42, in sell_artwork
    new_listing = Listing(artwork, price, self)
TypeError: object() takes no parameters

My code is below

class Art:
  def __init__(self, artist, title, medium, year, owner):
    self.artist = artist
    self.title = title
    self.medium = medium
    self.year = year
    self.owner = owner
    
  def __repr__(self):
    return "{}. \"{}\". {}, {}. {}, {}.".format(self.artist, self.title, self.year, self.medium, self.owner.name, self.owner.location)
 

class Marketplace:
  def __init__(self):
    self.listings = []     
    
  def add_listing(self, new_listing):
    self.listings.append(new_listing)
    
  def remove_listing(self, old_listing):
    self.listings.remove(old_listing)
  
  def show_listings(self):
    for listing in self.listings:
      print(listing)
      
class Client:
  def __init__(self, name, location, is_museum):
    self.name = name
    self.is_museum = is_museum
    if is_museum:
      self.location = location
    else:
      self.location = "Private Collection"
      
  def __repr__(self):
    print ("{}".format(self.name))
    
  
  def sell_artwork(self, artwork, price):
    if artwork.owner == self:
      new_listing = Listing(artwork, price, self)
      veneer.add_listing(new_listing)


class Listing:
  def __init(self, art, price, seller):
    self.art = art
    self.price = price
    self.seller = seller 
    
  def __repr_():
    return "{}, {}".format(self.art.title, self.price)
  # '%s, %s' % (self.art.title, self.price)


edytta = Client("Edytta Halpirt", None, False)

moma = Client("The MOMA", "New York", True)

veneer = Marketplace()

veneer.show_listings()
  
    # return "#s. \"%s\". %s, %s." % (self.artist, self.title, self.year, self.medium)

picasso = Art("Picasso, Pablo",  "Girl with a Mandolin (Fanny Tellier)", "oil on canvas", 1910, edytta)
print(picasso)

edytta.sell_artwork(picasso, "$6M (USD)")

veneer.show_listings()

Also, is using

 # return "#s. \"%s\". %s, %s." % (self.artist, self.title, self.year, self.medium)

better than using .format() ?

Hi there, welcome to the forums!

You have a typo in your Listing class… should be fairly obvious once you start looking. :slight_smile:

That’ll solve your immediate error.

1 Like

@thepitycoder Thank you so much!

Do you have any thoughts on the second part of the question?

About the string formatting?

I wouldn’t say I have a preference either way, tbh. I tend to default to using printf-style formatting, i.e.

  print("The value of the account is %0.02f" % balance)

but that’s probably more habit than anything else now.

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.