@@ -249,13 +249,22 @@ lookups. These are useful for making fast field extractors as arguments for
249249expect a function argument.
250250
251251
252- .. function :: attrgetter(attr[, args...])
252+ .. function :: attrgetter(attr)
253+ attrgetter(*attrs)
253254
254- Return a callable object that fetches *attr * from its operand. If more than one
255- attribute is requested, returns a tuple of attributes. After,
256- ``f = attrgetter('name') ``, the call ``f(b) `` returns ``b.name ``. After,
257- ``f = attrgetter('name', 'date') ``, the call ``f(b) `` returns ``(b.name,
258- b.date) ``. Equivalent to::
255+ Return a callable object that fetches *attr * from its operand.
256+ If more than one attribute is requested, returns a tuple of attributes.
257+ The attribute names can also contain dots. For example:
258+
259+ * After ``f = attrgetter('name') ``, the call ``f(b) `` returns ``b.name ``.
260+
261+ * After ``f = attrgetter('name', 'date') ``, the call ``f(b) `` returns
262+ ``(b.name, b.date) ``.
263+
264+ * After ``f = attrgetter('name.first', 'name.last') ``, the call ``f(b) ``
265+ returns ``(r.name.first, r.name.last) ``.
266+
267+ Equivalent to::
259268
260269 def attrgetter(*items):
261270 if any(not isinstance(item, str) for item in items):
@@ -275,14 +284,19 @@ expect a function argument.
275284 return obj
276285
277286
278- The attribute names can also contain dots; after ``f = attrgetter('date.month') ``,
279- the call ``f(b) `` returns ``b.date.month ``.
280-
281- .. function :: itemgetter(item[, args...])
287+ .. function :: itemgetter(item)
288+ itemgetter(*items)
282289
283290 Return a callable object that fetches *item * from its operand using the
284291 operand's :meth: `__getitem__ ` method. If multiple items are specified,
285- returns a tuple of lookup values. Equivalent to::
292+ returns a tuple of lookup values. For example:
293+
294+ * After ``f = itemgetter(2) ``, the call ``f(r) `` returns ``r[2] ``.
295+
296+ * After ``g = itemgetter(2, 5, 3) ``, the call ``g(r) `` returns
297+ ``(r[2], r[5], r[3]) ``.
298+
299+ Equivalent to::
286300
287301 def itemgetter(*items):
288302 if len(items) == 1:
@@ -321,9 +335,14 @@ expect a function argument.
321335
322336 Return a callable object that calls the method *name * on its operand. If
323337 additional arguments and/or keyword arguments are given, they will be given
324- to the method as well. After ``f = methodcaller('name') ``, the call ``f(b) ``
325- returns ``b.name() ``. After ``f = methodcaller('name', 'foo', bar=1) ``, the
326- call ``f(b) `` returns ``b.name('foo', bar=1) ``. Equivalent to::
338+ to the method as well. For example:
339+
340+ * After ``f = methodcaller('name') ``, the call ``f(b) `` returns ``b.name() ``.
341+
342+ * After ``f = methodcaller('name', 'foo', bar=1) ``, the call ``f(b) ``
343+ returns ``b.name('foo', bar=1) ``.
344+
345+ Equivalent to::
327346
328347 def methodcaller(name, *args, **kwargs):
329348 def caller(obj):
0 commit comments