Skip to content

Instantly share code, notes, and snippets.

@bogsio
Created October 28, 2013 19:32
Show Gist options
  • Save bogsio/7203100 to your computer and use it in GitHub Desktop.
Save bogsio/7203100 to your computer and use it in GitHub Desktop.
Understanding Python descriptors #5
class User(object):
email = EmailField()
...
class Company(object):
contact = EmailField()
...
user1 = User()
user1.email = '[email protected]'
print user1.email # [email protected]
user2 = User()
user2.email = '[email protected]'
print user2.email # [email protected]
print user1.email # [email protected]
print user2.email # [email protected]
company = Company()
company.contact = '[email protected]'
print company.contact # [email protected]
print EmailField._EmailField__email_dict
# {0: '[email protected]', 1: '[email protected]', 2: '[email protected]'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment