Skip to content

Instantly share code, notes, and snippets.

@kavirajk
Last active December 6, 2015 18:13
Show Gist options
  • Save kavirajk/ee51a1ef11ff4f6c6ba2 to your computer and use it in GitHub Desktop.
Save kavirajk/ee51a1ef11ff4f6c6ba2 to your computer and use it in GitHub Desktop.
Simple python getter and setter example
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