Documentation of multi-valued attributes unclear
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Beautiful Soup |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
The documentation on "multi_
https:/
* Python 3.8.10
* BeautifulSoup 4.8.2-1 (python3-bs4)
Using the same string as source, the documentation seems to suggest that there should be two different results, depending upon the use of the multi_valued_
>>> rel_soup = BeautifulSoup(
>>> rel_soup.a['rel']
['index']
>>> rel_soup.a['rel'] = ['index', 'contents']
>>> rel_soup.a['rel']
['index', 'contents']
>>> print(rel_soup.p)
<p>Back to the <a rel="index contents"
Adding in the multi_valued_
>>> rel_soup = BeautifulSoup(
>>> rel_soup.a['rel']
'index'
>>> rel_soup.a['rel'] = ['index', 'contents']
>>> rel_soup.a['rel']
['index', 'contents']
>>> print(rel_soup.p)
<p>Back to the <a rel="index contents"
Apparently, it does not work with the rel attribute. It using the class attribute in both examples would illustrate the contrast better:
Without the multi_valued_ attributes argument:
>>> no_list_soup = BeautifulSoup('<p class="body strikeout"></p>') soup.p[ 'class' ]
>>> no_list_
['body', 'strikeout']
With the multi_valued_ attributes argument:
>>> no_list_soup = BeautifulSoup('<p class="body strikeout"></p>', 'html', multi_valued_ attributes= None) soup.p[ 'class' ]
>>> no_list_
'body strikeout'