+ 3

Is there any possible way to delete a function which is inside a class?

I am trying to make a small game using pygame in python. I can't seem to find a method to delete a function which is inside a class 'Del' <function name> doesnt seem to work as it says calling func before assigning it

18th Aug 2020, 8:57 AM
Nikhil
Nikhil - avatar
6 odpowiedzi
+ 2
Say you have an enemy made out of your enemy class... enemy = Enemy() when enemy's health drops to 0 or below, enemy = None
18th Aug 2020, 9:12 AM
Slick
Slick - avatar
+ 1
Nikhil , Why do you want to delete a function?
18th Aug 2020, 9:02 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
Yes it works now thanksss
18th Aug 2020, 9:16 AM
Nikhil
Nikhil - avatar
0
To remove a character from the game
18th Aug 2020, 9:03 AM
Nikhil
Nikhil - avatar
0
You never want to do that. Why not work with deconstructors (opposite of __init__) or make a method that deletes a character once their health is gone
18th Aug 2020, 9:07 AM
Slick
Slick - avatar
0
But how can I delete the character Idk the syntax to delete it Will check on deconstructor
18th Aug 2020, 9:09 AM
Nikhil
Nikhil - avatar