Skip to content

Instantly share code, notes, and snippets.

@bogsio
Created October 28, 2013 19:30
Show Gist options
  • Save bogsio/7203071 to your computer and use it in GitHub Desktop.
Save bogsio/7203071 to your computer and use it in GitHub Desktop.
Understanding Python descriptors #2
from validate_email import validate_email
class EmailField(object):
def __get__(self, instance, owner):
return self.value
def __set__(self, instance, value):
validate_email(value)
self.value = value
class User(object):
email = EmailField()
def __init__(self):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment