hey everybody so in today's video I got to talk about the property decorator in Python the property decorator allows us to define a method as a property we can access it like it's an attribute one of the benefits is that when Reading Writing or deleting attributes we can add additional Logic the property decorator gives us a getter method to read a Setter method to write and a deleter method to delete when working with attributes in this example we'll create a class of rectangle we need a Constructor let's define that when constructing a rectangle object we will need a width and a height we will assign the attribute of width equal to the width that we receive when constructing this object self. height equals height let's construct a rectangle object rectangle equals rectangle we need to pass in a width and a height then I will print my rectangle's width rectangle. width and the height rectangle. height with my rectangle the width is three the height is four using the property decorator when reading these attributes of width or height I can write some additional logic let's say that when accessing the width or the height I would like to display one digit after the decimal then add centimet here's here's one way in which I can do that for each of these attributes I'm going to create a method we will Define a method of width no parameters besides self for now I'll write pass and Define height preceding each of these methods I will use the property decorator so at property now when accessing the width or the height will be returned with whatever is Within These methods of and height but there's one change we're going to make to these attributes we'll set these attributes to be private prefix each of these attributes with an underscore this tells you and other developers that these attributes they're meant to be protected they're internal we shouldn't access the width or the height directly outside of this class technically we could I will access the internal version of width and height we get three and four but we do have a warning access to a protected member width of a class that applies to height as well our width and our height are only meant to be used inside of this class if we need to get the width and the height we will do so through these getter methods provided by the property decorator so when accessing the width let's return an F string I will access self. private width add a format specifier to display one digit after the decimal 1f followed by CM we'll do this with the height as well we will return self. private height so now when we access the width or the height we will do so using these getter methods if I access these private width and height attributes instead again they will be three and four it's kind of like their raw these attributes are meant to be used internally inside of the class so that's the point of a getter method we can add additional logic when reading one of these attributes when we try to get them we can also add Setter methods if we would like to set or write these attributes here's how let's take our width we will create a decorator of at width. Setter when attempting to set the width we will do so using this method we will Define our method name of width we will have one parameter a new width we don't want the parameter name to be the same as the method name that's why we're naming it something different when setting the width let's check to see if the new width is greater than zero if so we will take self. private width equals our new width else let's print something let's print width must be greater than zero and let's do this with the height height. Setter Define height pass in a new height if our new height is greater than zero assign self. private height equals the new height else print height must be greater than zero before printing the width and the height let's take our rectangle width set it to be zero then see what happens well we get that message width must be greater than zero if I were to set width to be five well that does work our width is now five let's change the height rectangle. height I will set this to be negative one height must be greater than zero and the height hasn't changed what about six six does work when using these Setter methods we can add additional logic when writing or changing one of these attributes these are Setter methods now if you need to delete an attribute here's how there is a delete keyword we will delete our rectangle's width and delete our rectangle's height in this series we really won't be using the delete keyword but you should still know that it exists so we will create a deleter method at take one of the attributes in this example withd we will create a deleter method the method name will be width the name of the attribute there will be no parameters besides self we will delete self. private width then let's print something just to confirm that this was deleted width has been deleted same thing applies to height take the attribute of height Define height delete private height height has has been deleted when deleting our width or our height we get that confirmation message width has been deleted and height has been deleted all right everybody so that is the property decorator we can define a method as a property meaning it can be accessed as if it was an attribute one of the benefits is that we can add additional logic when we read write or delete attributes the property decorator gives us a getter Setter and deleter method getter methods to read Setter methods to write and deleter methods to delete and well everybody that is the property decorator in Python