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
def __get__(self, instance, owner): | |
""" | |
Instead of directly returning the value directory, we look up each instance's value using | |
the instance itself as the key. | |
""" | |
if instance is not None: # attribute lookup initiated from instance | |
if len(self._instance_values) < NonNullStringDescriptor.CAPACITY: | |
self._instance_values[instance] = self.__default | |
return self._instance_values.get(instance, self.__default) | |
else: # attribute lookup initiated via class | |
return self.__default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment