Veneer project - buy_artwork function won't work


I’m working on the Veneer project and am having trouble getting my buy_artwork function to work. It seems to have no effect whatsoever. Everything up to this point was working so if anyone knows what could be causing this, let me know. Thanks!

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,, location=self.owner.location)

class Marketplace:
  def __init__(self):
    self.listings = []
  def add_listing(self, new_listing):
  def remove_listing(self, old_listing):
  def show_listings(self):
    for listing in self.listings:
class Client:
  def __init__(self, name, location, is_museum): = name
    self.location = location
    self.is_museum = is_museum
  def sell_artwork(self, artwork, price):
    if artwork.owner == self:
      new_listing = Listing(self, artwork, price)

  def buy_artwork(self, artwork):
    if artwork.owner != self:
      art_listing = None
      for listing in veneer.listings:
        if == artwork:
          art_listing = listing
    if art_listing != None: = self

class Listing:
  def __init__(self, art, price, seller): = art
    self.price = price
    self.seller = seller
  def __repr__(self):
    return "%s, %s" %(, self.price)
edytta = Client("Edytta Halpirt", "Private Collection", 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))

veneer = Marketplace()

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




Hi @bbalagia

Consider this statement within the sell_artwork method of Client:

      new_listing = Listing(self, artwork, price)

What objects are being passed, via the arguments, to the __init__ method of Listing? For example, what does self represent in that statement?

Edited on February 12, 2019 to revise the questions asked above


self represents the Listing class, right?


The statement that we are discussing is part of the sell_artwork method of the Client class. That method has this header:

  def sell_artwork(self, artwork, price):

Therefore, in the statement under consideration, self represents the instance of Client from which the sell_artwork method is being called, rather than the instance of Listing that is involved in the sale. The instance of Client represented by self is the seller of the work of art.

Since we are creating an instance of Listing, we need to consider what arguments to pass to the __init__ method of Listing. This is the header of that method:

  def __init__(self, art, price, seller):

Note that the final parameter is seller. That parameter needs to receive the reference to the Client who is selling the art, namely self. So, here is how we make the call, matching the arguments to the parameters of the appropriate __init__ method:

      veneer.add_listing(Listing(artwork, price, self))