Veneer Project - Buy Artwork


I´m really struggling with classes and objects in Python and i would like someone to explain me the following code:
def buy_artwork(self, artwork):
if artwork.owner != self:
Because this is a method for the Client Class but uses artwork.owner and owner is from the Art class. If they are from different classes and theres was no inheritance, how this is going to associate the name of the art with the owner.

Thanks for your help

Because it’s a method with a parameter of artwork. So long as the object you pass to that parameter has a .owner attribute then it should be fine (I’d assume this would be an instance of Art).

1 Like

Hello, @kardoso78, and welcome to the Codecademy Forums!

Link to project page: Veneer

When you post code, it is best to format it so that indentation and other important details display correctly. See How to ask good questions (and get good answers for advice regarding how to format code for posting.

Your __init__ method for Art probably will have the following header after it is completed as of instruction 19:

  def __init__(self, artist, title, medium, year, owner):

Within that method, you will have this:

    self.owner = owner

Thereafter, when you instantiate Art, you will pass it the instance of Client that will own it.