@@ -241,13 +241,22 @@ lookups. These are useful for making fast field extractors as arguments for
241241expect a function argument.
242242
243243
244- .. function :: attrgetter(attr[, args...])
244+ .. function :: attrgetter(attr)
245+ attrgetter(*attrs)
245246
246- Return a callable object that fetches *attr * from its operand. If more than one
247- attribute is requested, returns a tuple of attributes. After,
248- ``f = attrgetter('name') ``, the call ``f(b) `` returns ``b.name ``. After,
249- ``f = attrgetter('name', 'date') ``, the call ``f(b) `` returns ``(b.name,
250- b.date) ``. Equivalent to::
247+ Return a callable object that fetches *attr * from its operand.
248+ If more than one attribute is requested, returns a tuple of attributes.
249+ The attribute names can also contain dots. For example:
250+
251+ * After ``f = attrgetter('name') ``, the call ``f(b) `` returns ``b.name ``.
252+
253+ * After ``f = attrgetter('name', 'date') ``, the call ``f(b) `` returns
254+ ``(b.name, b.date) ``.
255+
256+ * After ``f = attrgetter('name.first', 'name.last') ``, the call ``f(b) ``
257+ returns ``(r.name.first, r.name.last) ``.
258+
259+ Equivalent to::
251260
252261 def attrgetter(*items):
253262 if any(not isinstance(item, str) for item in items):
@@ -267,14 +276,19 @@ expect a function argument.
267276 return obj
268277
269278
270- The attribute names can also contain dots; after ``f = attrgetter('date.month') ``,
271- the call ``f(b) `` returns ``b.date.month ``.
272-
273- .. function :: itemgetter(item[, args...])
279+ .. function :: itemgetter(item)
280+ itemgetter(*items)
274281
275282 Return a callable object that fetches *item * from its operand using the
276283 operand's :meth: `__getitem__ ` method. If multiple items are specified,
277- returns a tuple of lookup values. Equivalent to::
284+ returns a tuple of lookup values. For example:
285+
286+ * After ``f = itemgetter(2) ``, the call ``f(r) `` returns ``r[2] ``.
287+
288+ * After ``g = itemgetter(2, 5, 3) ``, the call ``g(r) `` returns
289+ ``(r[2], r[5], r[3]) ``.
290+
291+ Equivalent to::
278292
279293 def itemgetter(*items):
280294 if len(items) == 1:
@@ -313,9 +327,14 @@ expect a function argument.
313327
314328 Return a callable object that calls the method *name * on its operand. If
315329 additional arguments and/or keyword arguments are given, they will be given
316- to the method as well. After ``f = methodcaller('name') ``, the call ``f(b) ``
317- returns ``b.name() ``. After ``f = methodcaller('name', 'foo', bar=1) ``, the
318- call ``f(b) `` returns ``b.name('foo', bar=1) ``. Equivalent to::
330+ to the method as well. For example:
331+
332+ * After ``f = methodcaller('name') ``, the call ``f(b) `` returns ``b.name() ``.
333+
334+ * After ``f = methodcaller('name', 'foo', bar=1) ``, the call ``f(b) ``
335+ returns ``b.name('foo', bar=1) ``.
336+
337+ Equivalent to::
319338
320339 def methodcaller(name, *args, **kwargs):
321340 def caller(obj):
0 commit comments