Skip to content

Instantly share code, notes, and snippets.

@cnorthwood
Created June 10, 2012 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cnorthwood/2907477 to your computer and use it in GitHub Desktop.
Save cnorthwood/2907477 to your computer and use it in GitHub Desktop.
>>> 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"]
>>> 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