Go to the documentation of this file.00001 class Options(dict):
00002
00003 def __init__(self, *args, **kw):
00004 dict.__init__(self, *args, **kw)
00005 self.readKeys = set()
00006
00007 def __getitem__(self, key):
00008 self.readKeys.add(key)
00009 return self.get(key,None)
00010
00011 def _unreadKeys(self):
00012 """return unused keys"""
00013 return set([a for a in self if a not in self.readKeys])
00014 unreadKeys = property(_unreadKeys)
00015
00016
00017
00018 if __name__ == "__main__":
00019 import unittest
00020 class TestOptions(unittest.TestCase):
00021 def testOptions(self):
00022 a = Options()
00023 a["A"] = 3
00024 a["B"] = 3
00025 a["A"]
00026 self.assertEqual(a.readKeys, set(["A"]))
00027 self.assertEqual(a.unreadKeys, set(["B"]))
00028
00029 unittest.main()