Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python getter decorator

class Person(object):
    def __init__(self, p_name=None):
        self.name = p_name

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, new_name):
        if type(new_name) == str: #type checking for name property
            self._name = new_name
        else:
            raise Exception("Invalid value for name")
Comment

PREVIOUS NEXT
Code Example
Python :: how to count special values in data in python 
Python :: kaggle vs colab 
Python :: 1 line if statement python 
Python :: remove rows from pandas dataframe that have text 
Python :: dataframe fill none 
Python :: find the closest smaller value in an array python 
Python :: how to round a number down in python 
Python :: how to translate to string to different alphabet python 
Python :: how to use ggplot matplotlib 
Python :: how to pick out separate columns from the pandas dataframe object 
Python :: How many columns have null values present in them? in pandas 
Python :: Read XML file to Pandas DataFrame 
Python :: how to count unique values in a column dataframe in python 
Python :: sparse categorical cross entropy python 
Python :: create text file in directory python linux 
Python :: python list all files of directory in given pattern 
Python :: python3 change file permissions 
Python :: how to check python version on terminal 
Python :: transform categorical variables python 
Python :: python ndim 
Python :: calculating mean for pandas column 
Python :: convert string to list of dictionaries 
Python :: measure cell execution time in jupyter notebook 
Python :: find most frequent element in an array python 
Python :: pandas groupby aggregate multiple columns 
Python :: capitalise words in a column pandas 
Python :: sleep in python 3 
Python :: specify the number of decimals in a dataframe 
Python :: python with statement file does not exist exception 
Python :: df only take 2 columns 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =