Skip to content

Instantly share code, notes, and snippets.

@alanbriolat
Created May 30, 2012 21:34
Show Gist options
  • Save alanbriolat/2839097 to your computer and use it in GitHub Desktop.
Save alanbriolat/2839097 to your computer and use it in GitHub Desktop.
Descriptors gone wrong
class Color(object):
def __init__(self, initial=None):
self.value = initial
def __get__(self, obj, objtype):
return self.value
def __set__(self, obj, value):
self.value = value
class Style(object):
# These will always be the same color! Do not want.
color = Color()
bgcolor = Color()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment