Computer Science 1026A/B Lecture Notes - Docstring, Init

11 views9 pages
terubarenuka and 39895 others unlocked
COMPSCI 1026A/B Full Course Notes
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents

Document Summary

Python property() function returns the object of the property class and it is used to create property of a class. Fget() used to get the value of attribute. Fset() used to set the value of attribute. Fdel() used to delete the attribute value. Doc() string that contains the documentation (docstring) for the attribute. Return: returns a property attribute from the given getter, setter and deleter. If no arguments are given, property() method returns a base property attribute that doesn"t contain any getter, setter or deleter. If doc isn"t provided, property() method takes the docstring of the getter function. Another way to do the same thing mentioned above. # alphabet class class alphabet: def __init__(self, value): self. _value = value. # getting the values def getvalue(self): print("getting value") return self. _value. # setting the values def setvalue(self, value): print("setting value to " + value) self. _value = value. # deleting the values def delvalue(self): print("deleting value") del self. _value value = property(getvalue, setvalue, delvalue, )

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions