All pastes #506676 Raw Edit

mmoreno80

public text v1 · immutable
·published 2007-05-24 03:43 UTC
rendered paste body
class XtermDict (dict):
    RANDOM, ARGS = range(2)
    def __getattribute__ (self, key):
        attribute = dict.__getattribute__(self, key)
        return attribute[XtermDict.ARGS]
    def random (self, key):
        #assert self.has_key[key]
        return self[key][XtermDict.RANDOM]

xtermDict = XtermDict()
xtermDict['foo'] = True, 'Bar'
print xtermDict['foo']
print xtermDict.random('foo')

#################################(True, 'Bar')
Traceback (most recent call last):
  File "<stdin>", line 50, in <module>
  File "<stdin>", line 42, in __getattribute__
TypeError: 'instancemethod' object is unsubscriptable