Commits

Jason R. Coombs committed ffd931d

Added support for contains in the FoldedCaseKeyedDict

  • Participants
  • Parent commits b9dadd1

Comments (0)

Files changed (1)

File jaraco/util/dictlib.py

 	{u'heLlo': u'world'}
 	>>> d['hello']
 	u'world'
+	>>> 'hello' in d
+	True
+	>>> 'HELLO' in d
+	True
 	>>> FoldedCaseKeyedDict({'heLlo': 'world'})
 	{u'heLlo': u'world'}
 	>>> d = FoldedCaseKeyedDict({'heLlo': 'world'})
 		for item in d.items():
 			self.__setitem__(*item)
 
+	def __contains__(self, key):
+		if isinstance(key, basestring):
+			key = jaraco.util.string.FoldedCase(key)
+		return super(FoldedCaseKeyedDict, self).__contains__(key)
+
 class DictAdapter(object):
 	"""
 	Provide a getitem interface for attributes of an object.