mirror of
https://github.com/python/cpython
synced 2026-09-29 11:35:29 +03:00
#16523: improve attrgetter/itemgetter/methodcaller documentation.
This commit is contained in:
parent
c58a3ea72c
commit
babc8227cc
2 changed files with 40 additions and 21 deletions
|
|
@ -460,8 +460,8 @@ PyDoc_STRVAR(itemgetter_doc,
|
|||
"itemgetter(item, ...) --> itemgetter object\n\
|
||||
\n\
|
||||
Return a callable object that fetches the given item(s) from its operand.\n\
|
||||
After, f=itemgetter(2), the call f(r) returns r[2].\n\
|
||||
After, g=itemgetter(2,5,3), the call g(r) returns (r[2], r[5], r[3])");
|
||||
After f = itemgetter(2), the call f(r) returns r[2].\n\
|
||||
After g = itemgetter(2, 5, 3), the call g(r) returns (r[2], r[5], r[3])");
|
||||
|
||||
static PyTypeObject itemgetter_type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
|
|
@ -712,9 +712,9 @@ PyDoc_STRVAR(attrgetter_doc,
|
|||
"attrgetter(attr, ...) --> attrgetter object\n\
|
||||
\n\
|
||||
Return a callable object that fetches the given attribute(s) from its operand.\n\
|
||||
After, f=attrgetter('name'), the call f(r) returns r.name.\n\
|
||||
After, g=attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\
|
||||
After, h=attrgetter('name.first', 'name.last'), the call h(r) returns\n\
|
||||
After f = attrgetter('name'), the call f(r) returns r.name.\n\
|
||||
After g = attrgetter('name', 'date'), the call g(r) returns (r.name, r.date).\n\
|
||||
After h = attrgetter('name.first', 'name.last'), the call h(r) returns\n\
|
||||
(r.name.first, r.name.last).");
|
||||
|
||||
static PyTypeObject attrgetter_type = {
|
||||
|
|
@ -844,8 +844,8 @@ PyDoc_STRVAR(methodcaller_doc,
|
|||
"methodcaller(name, ...) --> methodcaller object\n\
|
||||
\n\
|
||||
Return a callable object that calls the given method on its operand.\n\
|
||||
After, f = methodcaller('name'), the call f(r) returns r.name().\n\
|
||||
After, g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\
|
||||
After f = methodcaller('name'), the call f(r) returns r.name().\n\
|
||||
After g = methodcaller('name', 'date', foo=1), the call g(r) returns\n\
|
||||
r.name('date', foo=1).");
|
||||
|
||||
static PyTypeObject methodcaller_type = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue