create account

WORKING WITH DESTRUCTOR METHOD IN PYTHON!! by leoumesh

View this thread on: hive.blogpeakd.comecency.com
· @leoumesh ·
$0.11
WORKING WITH DESTRUCTOR METHOD IN PYTHON!!
```
class Student:
    def __init__(self,name,age, gender,major):
        self.name=name
        self.age=age
        self.gender=gender
        self.major=major
    
        
       
    def __del__(self):
        print("The student records has been deleted successfully.")
```

The series of output is as follows:


![pyython.png](https://cdn.steemitimages.com/DQmQJcjH6QbVj4nTvpXJxKPhsdCoymAbf324dsX6S455kak/pyython.png)

I typed this code in IDLE and then run the module. After running the module, I created an object called "Student1" and pass the required values, then checked it. By calling **del** method the object was destroyed and thus trying to access any state of that previous object gives the output as "Student1 is not defined."
👍  , , , , , , , , , , ,
properties (23)
authorleoumesh
permlinkworking-with-destructor-method-in-python
categorypython
json_metadata{"tags":["python","coding","programming","learning","programmer"],"image":["https://cdn.steemitimages.com/DQmQJcjH6QbVj4nTvpXJxKPhsdCoymAbf324dsX6S455kak/pyython.png"],"app":"steemit/0.2","format":"markdown"}
created2020-03-14 14:10:24
last_update2020-03-14 14:10:24
depth0
children2
last_payout2020-03-21 14:10:24
cashout_time1969-12-31 23:59:59
total_payout_value0.054 HBD
curator_payout_value0.053 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length744
author_reputation212,340,493,251,438
root_title"WORKING WITH DESTRUCTOR METHOD IN PYTHON!!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,347,695
net_rshares444,566,809,867
author_curate_reward""
vote details (12)
@beerlover ·
<div class='pull-right'>https://cdn.steemitimages.com/DQmaHThyECGhEx8tSfHZbiMFRNYjJ35K92cDgiJjkzBUaJo/One%20sip%20of%20BEER%20for%20you.gif<p><sup><a href='https://steem-engine.com/?p=market&t=BEER'>View or trade </a> <code>BEER</code>.</sup></p></div><center><br> <p> Hey @leoumesh, here is a little bit of <code>BEER</code> from @isnochys for you. Enjoy it!</p> <p>Learn how to <a href='https://steemit.com/beer/@beerlover/what-is-proof-of-stake-with-beer'>earn FREE BEER each day </a> by staking.</p> </center><div></div>
properties (22)
authorbeerlover
permlinkre-working-with-destructor-method-in-python-20200315t103845z
categorypython
json_metadata"{"app": "beem/0.21.1"}"
created2020-03-15 10:38:48
last_update2020-03-15 10:38:48
depth1
children0
last_payout2020-03-22 10:38:48
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length524
author_reputation25,782,713,665,946
root_title"WORKING WITH DESTRUCTOR METHOD IN PYTHON!!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,371,699
net_rshares0
@isnochys ·
Have a witness !BEER
properties (22)
authorisnochys
permlinkre-working-with-destructor-method-in-python-20200315t103833
categorypython
json_metadata""
created2020-03-15 10:38:36
last_update2020-03-15 10:38:36
depth1
children0
last_payout2020-03-22 10:38:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length20
author_reputation47,917,144,909,021
root_title"WORKING WITH DESTRUCTOR METHOD IN PYTHON!!"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id96,371,694
net_rshares0