What is a deleter in OOPs in python

This recipe explains what is a deleter in OOPs in python

Recipe Objective

This recipe explains what is a Deleter.

Access Face Recognition Project Code using Facenet in Python

Deleter

Deleter method can be defined for any attribute using @property in Python. Deleter method deletes the attribute from the memory.

 

# Deleter
class student:
    def __init__(self, name, birth_year, age):
        self.name = name
        self.birth_year = birth_year
        self.age = age 
        
    @property    
    def email(self):
        if(self.name == None):
            return "Member not found"
        return str(self.name) + "." + str(self.birth_year) + "@gmail.com"
    
    @email.setter
    def email(self, clg_email):
        name, birth_year = clg_email.split("@")[0].split(".")
        self.name = name
        self.birth_year = birth_year
    
    @email.deleter
    def email(self):
        self.name = None
        self.birth_year = None
        self.age = None

Max = student("max", 2001, 20)
print(Max.email)

del Max.email
print(Max.email)

 

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Loan Eligibility Prediction Project using Machine learning on GCP
Loan Eligibility Prediction Project - Use SQL and Python to build a predictive model on GCP to determine whether an application requesting loan is eligible or not.

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Model Deployment on GCP using Streamlit for Resume Parsing
Perform model deployment on GCP for resume parsing model using Streamlit App.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

NLP Project for Beginners on Text Processing and Classification
This Project Explains the Basic Text Preprocessing and How to Build a Classification Model in Python