From 92ad5e0dee9503f507f6277b493dfa96010f3a44 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Sun, 28 Jun 2015 14:08:48 -0400 Subject: Copying a NavigableString will give you a new NavigableString that is not connected to the parse tree. --- bs4/element.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bs4/element.py') diff --git a/bs4/element.py b/bs4/element.py index d1b7c12..0486da2 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -689,7 +689,10 @@ class NavigableString(unicode, PageElement): return u def __copy__(self): - return self + """A copy of a NavigableString has the same contents and class + as the original, but it is not connected to the parse tree. + """ + return type(self)(self) def __getnewargs__(self): return (unicode(self),) -- cgit v1.2.3