| Paste number 7539: | XPath-like Suggestion for Amara |
| Pasted by: | sbp |
| When: | 7 years, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+5TF |
| Channel: | #swhack |
| Paste contents: |
>>> class Element(object):
... attributes = {'something': 'blargh'}
... children = ['p', 'q', 'r']
... def __div__(self, path):
... if path.startswith('@'):
... if self.attributes.has_key(path[1:]):
... return self.attributes[path[1:]]
... else: return self.children[self.children.index(path)]
...
>>> elem = Element()
>>> elem/'@something'
'blargh'
>>> elem/'q'
'q'
>>>
This paste has no annotations.