diff options
author | Leonard Richardson <leonardr@segfault.org> | 2018-07-15 20:04:03 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2018-07-15 20:04:03 -0400 |
commit | 75c81928902b3f2896cbd3482a59828965627916 (patch) | |
tree | d20036348c7aecb0309e6b362f211d65b340db03 /bs4/__init__.py | |
parent | a98b0e4b7cd1d0c61eebc50efabc6bc7876b50a0 (diff) |
You can pass a dictionary of into
BeautifulSoup.new_tag. This makes it possible to create a tag with
an attribute like 'name' that would otherwise be masked by another
argument of new_tag. [bug=1779276]
Diffstat (limited to 'bs4/__init__.py')
-rw-r--r-- | bs4/__init__.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index 329ef53..409f528 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -356,9 +356,10 @@ class BeautifulSoup(Tag): self.preserve_whitespace_tag_stack = [] self.pushTag(self) - def new_tag(self, name, namespace=None, nsprefix=None, **attrs): + def new_tag(self, name, namespace=None, nsprefix=None, attrs={}, **kwattrs): """Create a new tag associated with this soup.""" - return Tag(None, self.builder, name, namespace, nsprefix, attrs) + kwattrs.update(attrs) + return Tag(None, self.builder, name, namespace, nsprefix, kwattrs) def new_string(self, s, subclass=NavigableString): """Create a new NavigableString associated with this soup.""" |