From 37f53a378ddab1c67a54448bb87cb61b5e122a44 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 3 Jun 2013 11:38:23 -0400 Subject: 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. --- bs4/element.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'bs4/element.py') 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. -- cgit v1.2.3