Created
June 7, 2012 12:46
-
-
Save bertonha/2888639 to your computer and use it in GitHub Desktop.
tOSM some Ideas
This file contains hidden or 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 _BaseProperty(object): | |
def __set__(self, instance, value): | |
self._implicid_validation(value) | |
self.__validate(value) | |
# this way you dont look every time for attr_name | |
if not hasattr(self, 'attr_name'): | |
for attr_name, attr_value in instance.__class__.__dict__.items(): | |
if attr_value == self: | |
self.attr_name = '_attributename_'+attr_name | |
break | |
setattr(instance, self.attr_name, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment