Veneer Attribute Error

Hello, I’m having some trouble fixing my code…in this lesson: https://www.codecademy.com/paths/computer-science/tracks/cspath-cumulative-art-marketplace/modules/cspath-veneer/projects/veneer

Here is my code so far:

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 '''{artist}. "{title}". {year}, {medium}. {owner}, {location}.'''.format(artist = self.artist, title = self.title, year = self.year, medium = self.medium, owner = self.owner.name, location = 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
    if is_museum == True:
      self.location = location
    else:
      self.location = "private collection"

  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 = self
    self.price = price
    self.seller = seller

  def __repr__(self):
    return "{title}, {price}.".format(title = self.art.title, price = self.price)

veneer = Marketplace()
print(veneer.show_listings())

edytta = Client("Edytta Halpirt", None, False)
moma = Client("The MOMA", "New York", True)

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


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

veneer.show_listings()

It’s at the string representation in the Listing class:
AttributeError: ‘Listing’ object has no attribute ‘title’

Thanks for the help!!

If you’ve narrowed it down to that string then keep working at it. You only use the .title attribute once in this class, when printing with the line self.art.title. Perhaps you should double-check what self.art is.

1 Like

Thank you! I found the error. I didn’t realise I’d made a mistake there.

1 Like

You were on the way to it but it’s worth following that thread a little further. Using some basic debugging or even print is a nice way to just give yourself a little sanity check.

1 Like