-
-
Save davbo/2907505 to your computer and use it in GitHub Desktop.
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 IdentifierList(list): | |
... def by_namespace(self): | |
... return None | |
... | |
>>> class Locality(): | |
... @property | |
... def identifiers(self): | |
... return IdentifierList(self._identifiers) | |
... @identifiers.setter | |
... def identifiers(self, value): | |
... self._identifiers = value | |
... | |
>>> l = Locality() | |
>>> l.identifiers = ["hello"] # assigning a list? | |
>>> l.identifiers.append("hello") # don't you want something more like this? | |
>>> l.identifiers | |
['hello'] | |
>>> l.identifiers.by_namespace | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
AttributeError: 'list' object has no attribute 'by_namespace' | |
>>> type(l.identifiers) | |
<type 'list'> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment