Python property() function
Published February 16, 2022In Python, the property() function returns an object of the property class, and it can be used to create a property of a class. Property() returns an object of the property class as an argument, taking the delete, set, and get methods as arguments.
The Syntax of Property() method
The syntax of the property() method includes:
property(get(), set(), del(), doc()) |
where:
get()- gets the attribute value
set()- sets the attribute value
del()- deletes the attribute value
doc()- contains the documentation of the attribute
Example
class Person: |
Output
Get name |
Article Contributed By :
|
|
|
|
303 Views |