Skip to content

Commit 5715939

Browse files
authored
Tune multidict docs (#1205)
1. Put `extend()` and `update()` docs in the same logical group to display bulk update methods together 2. Mention `kwargs` as accepted argument for both `extend()` and `update()`.
1 parent 8dc666e commit 5715939

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

CHANGES/1205.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improved documentation for :meth:`multidict.MultiDict.extend` and :meth:`multidict.MultiDict.update` -- by :user:`asvetlov`.

docs/multidict.rst

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,6 @@ MultiDict
7171

7272
Return a shallow copy of the dictionary.
7373

74-
.. method:: extend([other])
75-
76-
Extend the dictionary with the key/value pairs from *other*,
77-
appending the pairs to this dictionary. For existing keys,
78-
values are added.
79-
Returns ``None``.
80-
81-
:meth:`extend` accepts either another dictionary object or an
82-
iterable of key/value pairs (as tuples or other iterables of
83-
length two). If keyword arguments are specified, the dictionary
84-
is then extended with those key/value pairs:
85-
``d.extend(red=1, blue=2)``.
86-
87-
Effectively the same as calling :meth:`add` for every
88-
``(key, value)`` pair. Also see :meth:`update`, for a version
89-
that replaces existing keys.
90-
9174
.. method:: getone(key[, default])
9275

9376
Return the **first** value for *key* if *key* is in the
@@ -179,9 +162,30 @@ MultiDict
179162
If not, insert *key* with a value of *default* and return *default*.
180163
*default* defaults to ``None``.
181164

182-
.. method:: update([other])
165+
.. method:: extend([other], **kwargs)
166+
167+
Extend the dictionary with the key/value pairs from *other* and *kwargs*,
168+
appending the pairs to this dictionary. For existing keys,
169+
values are added.
183170

184-
Update the dictionary with the key/value pairs from *other*,
171+
Returns ``None``.
172+
173+
:meth:`extend` accepts either another dictionary object or an
174+
iterable of key/value pairs (as tuples or other iterables of
175+
length two). If keyword arguments are specified, the dictionary
176+
is then extended with those key/value pairs:
177+
``d.extend(red=1, blue=2)``.
178+
179+
Effectively the same as calling :meth:`add` for every
180+
``(key, value)`` pair.
181+
182+
.. seealso::
183+
184+
:meth:`update`
185+
186+
.. method:: update([other], **kwargs)
187+
188+
Update the dictionary with the key/value pairs from *other* and *kwargs*,
185189
overwriting existing keys.
186190

187191
Returns ``None``.
@@ -192,8 +196,9 @@ MultiDict
192196
dictionary is then updated with those key/value pairs:
193197
``d.update(red=1, blue=2)``.
194198

195-
Also see :meth:`extend` for a method that adds to existing keys rather
196-
than update them.
199+
.. seealso::
200+
201+
:meth:`extend`
197202

198203
.. seealso::
199204

@@ -444,7 +449,7 @@ Environment variables
444449
its C counterpart, depending on the way it's used.
445450

446451
.. envvar:: MULTIDICT_DEBUG_BUILD
447-
452+
448453
An environment variable that instructs the packaging scripts to compile
449454
the C-extension based variant of :mod:`multidict` with debug symbols.
450455
This is useful for debugging the C-extension code, but it will result in

0 commit comments

Comments
 (0)