From 2e327a4d1e8defeadb78be098bc48b99b2175b46 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Sat, 11 May 2013 00:07:50 -0400 Subject: [PATCH] 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__`. --- zipline/protocol.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zipline/protocol.py b/zipline/protocol.py index ec052721..34462b0a 100644 --- a/zipline/protocol.py +++ b/zipline/protocol.py @@ -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