MAINT: Add a has_key method to BarData for compatibility.

BarData should, at least for the time being, be compatible with
existing algorithms that had worked against the prior usage of
an ndict as data, which provided `has_key`.

Of note, the Python language has deprecated `has_key` in favor
of using `in` and `__contains__`.
This commit is contained in:
Eddie Hebert
2013-05-11 00:07:50 -04:00
parent 4177a2c073
commit 2e327a4d1e
+7
View File
@@ -144,6 +144,13 @@ class BarData(object):
else:
return name in self.__dict__
def has_key(self, name):
"""
DEPRECATED: __contains__ is preferred, but this method is for
compatibility with existing algorithms.
"""
return name in self
def __setitem__(self, name, value):
self._data[name] = value