Last active
December 6, 2015 18:13
-
-
Save kavirajk/ee51a1ef11ff4f6c6ba2 to your computer and use it in GitHub Desktop.
Simple python getter and setter example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailField(object): | |
def __init__(self, email=None): | |
self.email = email | |
def __set__(self, email): | |
self.email = email | |
def __get__(self, email): | |
return self.email | |
class User(object): | |
email = EmailField('[email protected]') | |
obj = User() | |
obj.email | |
#output '[email protected]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment