diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2013-06-03 11:38:23 -0400 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2013-06-03 11:38:23 -0400 |
commit | 37f53a378ddab1c67a54448bb87cb61b5e122a44 (patch) | |
tree | cf9fad56204fffdaaf1fa5c3982a0c627ee08057 /bs4/element.py | |
parent | f5ff09d09ef6c60f5d5052fac25d4e128bdce34f (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 742624d..f248895 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -674,6 +674,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. |