Veneer exercise


#1

Veneer

what’s wrong with my code? when i print the last three lines i get

<main.Client object at 0x7f4e353124a8>

<main.Client object at 0x7f4e353124e0>

Picasso, Pablo. “Girl with a Mandolin (Fanny Tellier)”. 1910, oil on canvas, <main.Client object at 0x7f4e353124a8>, Private Collection.

i checked out the walkthrough video and wrote the same Client class too nothing changed

class Art:
  def __init__(self, artist, title, year, medium, 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_name}, {owner_loc}.'.format(artist=self.artist, title=self.title, year=self.year, medium=self.medium, owner_name=self.owner, owner_loc=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, expired):
    self.listings.remove(expired)
  
  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"



veneer = Marketplace()
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)", 1910, "oil on canvas", edytta)

print(edytta)
print(moma)
print(girl_with_mandolin)

#2

If you expected something else then identify what that difference is and argue for it. Then check that argument against your code - because if you can argue for why something should happen there’s corresponding code for that, or if not, that’s what you’d need to write to eliminate the difference.

The word “wrong” is similar to describing a location as “here”, or over the phone declaring that it’s “me”. It doesn’t actually contain that information.


#3

thank you for your reply I was referring to this (I don’t know what it’s called)

< main .Client object at 0x7f4e353124a8>

I was getting this when I printed the last statements instead of

Edytta Halpirt, Private Collection, False

not sure if I made it clear with my sloppy english but I found out the problem I only looked at the walkthrough video for the exercise and there was no repr method on the Client class I only added the method and now it works fine

> 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):
>     return '{name}, {location}, {is_museum}'.format(name=self.name, location=self.location, is_museum=self.is_museum)

#4

That’s what I was fishing for, yes. Either you expected nothing to be printed, and yet got something (remove the print) or you expected something else (there would need to be code for that, or there shouldn’t be any expectations and therefore it couldn’t be different from expectations, or in other words, it wouldn’t be wrong)