mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
indent properly
This commit is contained in:
parent
b46b9d59ef
commit
ffec810d88
1 changed files with 9 additions and 9 deletions
|
@ -344,15 +344,15 @@ expect a function argument.
|
||||||
operand's :meth:`__getitem__` method. If multiple items are specified,
|
operand's :meth:`__getitem__` method. If multiple items are specified,
|
||||||
returns a tuple of lookup values. Equivalent to::
|
returns a tuple of lookup values. Equivalent to::
|
||||||
|
|
||||||
def itemgetter(*items):
|
def itemgetter(*items):
|
||||||
if len(items) == 1:
|
if len(items) == 1:
|
||||||
item = items[0]
|
item = items[0]
|
||||||
def g(obj):
|
def g(obj):
|
||||||
return obj[item]
|
return obj[item]
|
||||||
else:
|
else:
|
||||||
def g(obj):
|
def g(obj):
|
||||||
return tuple(obj[item] for item in items)
|
return tuple(obj[item] for item in items)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
The items can be any type accepted by the operand's :meth:`__getitem__`
|
The items can be any type accepted by the operand's :meth:`__getitem__`
|
||||||
method. Dictionaries accept any hashable value. Lists, tuples, and
|
method. Dictionaries accept any hashable value. Lists, tuples, and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue