Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python setter getter deleter

class C(object):
    def __init__(self):
        self._x = None

    @property
    def x(self):
        """I'm the 'x' property."""
        print("getter of x called")
        return self._x

    @x.setter
    def x(self, value):
        print("setter of x called")
        self._x = value

    @x.deleter
    def x(self):
        print("deleter of x called")
        del self._x


c = C()
c.x = 'foo'  # setter called
foo = c.x    # getter called
del c.x      # deleter called
Comment

PREVIOUS NEXT
Code Example
Python :: standardscaler into df data frame pandas 
Python :: pytorch plt.imshow 
Python :: how to check if left mousebuttondown in pygame 
Python :: drop rows that contain null values in a pandas dataframe 
Python :: dj_database_url 
Python :: add conda env to jupyter 
Python :: installing django 
Python :: use selenium without opening browser 
Python :: reverse row order pandas 
Python :: pytorch check if cuda is available 
Python :: how to get just the filename in python 
Python :: change size of selenium window 
Python :: ndarray to pil image 
Python :: how to check datatype of column in dataframe python 
Python :: put comma in numbers python 
Python :: flask get ip address of request 
Python :: webbrowser python could not locate runnable browser 
Python :: how can I sort a dictionary in python according to its values? 
Python :: random character generator python 
Python :: python sort dictionary alphabetically by key 
Python :: python virtual environment 
Python :: tensorflow load h5 model 
Python :: opencv draw two images side by side 
Python :: ban discord.py 
Python :: get image height width cv2 
Python :: python infinite value 
Python :: dns request scapy 
Python :: sklearn rmsle 
Python :: reverse dictionary python 
Python :: E: Unable to locate package python3-pip 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =