diff options
author | Leonard Richardson <leonardr@segfault.org> | 2013-05-20 11:45:08 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2013-05-20 11:45:08 -0400 |
commit | b289252da31f1824ee9c85f1ce53907069d6dd7e (patch) | |
tree | bfc6115d76306aa871ad157142314049809d2748 /bs4/element.py | |
parent | 612922241894abf0467e77c12fc4bb8aa130ac41 (diff) |
A NavigableString object now has an immutable '.name' property whose
value is always None. This makes it easier to iterate over a mixed
list of tags and strings without having to check whether each
element is a tag or a string.
Diffstat (limited to 'bs4/element.py')
-rw-r--r-- | bs4/element.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bs4/element.py b/bs4/element.py index f6864f2..538f6b6 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -672,6 +672,13 @@ class NavigableString(unicode, PageElement): output = self.format_string(self, formatter) return self.PREFIX + output + self.SUFFIX + @property + def name(self): + return None + + @name.setter + def name(self, name): + raise AttributeError("A NavigableString cannot be given a name.") class PreformattedString(NavigableString): """A NavigableString not subject to the normal formatting rules. |