Created
May 30, 2012 21:34
-
-
Save alanbriolat/2839097 to your computer and use it in GitHub Desktop.
Descriptors gone wrong
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 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