Skip to content

Instantly share code, notes, and snippets.

@bertonha
Created June 7, 2012 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertonha/2888639 to your computer and use it in GitHub Desktop.
Save bertonha/2888639 to your computer and use it in GitHub Desktop.
tOSM some Ideas
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