summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2016-12-10 14:08:54 -0500
committerLeonard Richardson <leonardr@segfault.org>2016-12-10 14:08:54 -0500
commit264d1b9184ba5acb2cae3b7f8aa083da50975468 (patch)
tree037af34a409b28ccd8368e8a74a9dd2cefdb3814
parente5070b5b99c8aecb5d20d549cd1f85e70edd6268 (diff)
downloadbeautifulsoup4-264d1b9184ba5acb2cae3b7f8aa083da50975468.tar.gz
Corrected documentation left over from when class was treated as a single-valued attribute. [bug=1631743]
-rw-r--r--doc/source/index.rst22
1 files changed, 11 insertions, 11 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 5572eff..654a3a4 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -360,34 +360,34 @@ Attributes
^^^^^^^^^^
A tag may have any number of attributes. The tag ``<b
-class="boldest">`` has an attribute "class" whose value is
+id="boldest">`` has an attribute "id" whose value is
"boldest". You can access a tag's attributes by treating the tag like
a dictionary::
- tag['class']
+ tag['id']
# u'boldest'
You can access that dictionary directly as ``.attrs``::
tag.attrs
- # {u'class': u'boldest'}
+ # {u'id': 'boldest'}
You can add, remove, and modify a tag's attributes. Again, this is
done by treating the tag as a dictionary::
- tag['class'] = 'verybold'
- tag['id'] = 1
+ tag['id'] = 'verybold'
+ tag['another-attribute'] = 1
tag
- # <blockquote class="verybold" id="1">Extremely bold</blockquote>
+ # <b another-attribute="1" id="verybold"></b>
- del tag['class']
del tag['id']
+ del tag['another-attribute']
tag
- # <blockquote>Extremely bold</blockquote>
+ # <b></b>
- tag['class']
- # KeyError: 'class'
- print(tag.get('class'))
+ tag['id']
+ # KeyError: 'id'
+ print(tag.get('id'))
# None
.. _multivalue: