summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2013-05-14 08:39:16 -0400
committerLeonard Richardson <leonardr@segfault.org>2013-05-14 08:39:16 -0400
commit2738a3bb506ba3b87aa19fcc2846594e279f4dd3 (patch)
treeca49a12ee8f1f4129b321575a750c66d99d029ff /bs4/element.py
parent9ce6c22ae13c745ee31a06db1ace2e3d685204af (diff)
Added a deprecation warning to has_key().
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 1f121f4..f6864f2 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1392,10 +1392,13 @@ class Tag(PageElement):
def recursiveChildGenerator(self):
return self.descendants
- # This was kind of misleading because has_key() (attributes) was
- # different from __in__ (contents). has_key() is gone in Python 3,
- # anyway.
- has_key = has_attr
+ def has_key(self, key):
+ """This was kind of misleading because has_key() (attributes)
+ was different from __in__ (contents). has_key() is gone in
+ Python 3, anyway."""
+ warnings.warn('has_key is deprecated. Use has_attr("%s") instead.' % (
+ key))
+ return self.has_attr(key)
# Next, a couple classes to represent queries and their results.
class SoupStrainer(object):