summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/bs4/element.py b/bs4/element.py
index fdb90e0..7e5810a 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -24,11 +24,22 @@ def _alias(attr):
class NamespacedAttribute(object):
- def __init__(self, namespace_abbreviation, name, namespace):
+ def __init__(self, namespace_abbreviation, name, namespace=None):
self.namespace_abbreviation = namespace_abbreviation
self.name = name
self.namespace = namespace
+ def __eq__(self, other):
+ if isinstance(other, NamespacedAttribute):
+ return (
+ self.namespace_abbreviation == other.namespace_abbreviation
+ and self.name == other.name
+ and self.namespace == other.namespace)
+ elif isinstance(other, basestring):
+ return str(self) == other
+ else:
+ return super(NamespacedAttribute, self).__eq__(other)
+
def __str__(self):
name = self.name
if self.namespace_abbreviation: