I'm using property() for setting up getters and setters for a Class
Here's the code:
class Person:
    def __init__(self, email=None):
        self.email = email
    def set_email(self, value):
        self._email = value
    def get_email(self):
        return self._email
    email = property(get_email, set_email)
if __name__ == "__main__":
    try:
        contact = Person(email="abc@123")
    except Exception as e:
        print(e)
This code work perfect, but, when I change self._email to self.email inside set_email() to this:
def set_email(self, value):
        self.email = value
I am getting:
self.email = value
[Previous line repeated 494 more times]
RecursionError: maximum recursion depth exceeded
I understand that a single underscore before a variable denotes that the variable is for internal use only.
But I can't understand why do I need to use self._email even though I have used self.email in the constructor.
Can anyone explain why is this happening?
 
    