Benx Shen's personal annotations on this page
Benxshen bookmarked
on 2009-10-20
-
- operator.itemgetter(item[, args...])¶
Return a callable object that fetches item from its operand using the
operand’s __getitem__() method. If multiple items are specified,
returns a tuple of lookup values. Equivalent to:def itemgetter(*items):
if len(items) == 1:
item = items[0]
def g(obj):
return obj[item]
else:
def g(obj):
return tuple(obj[item] for item in items)
return g
This link has been bookmarked by 1 people . It was first bookmarked on 20 Oct 2009, by Benx Shen.
-
-
- operator.itemgetter(item[, args...])¶
Return a callable object that fetches item from its operand using the
operand’s __getitem__() method. If multiple items are specified,
returns a tuple of lookup values. Equivalent to:def itemgetter(*items):
if len(items) == 1:
item = items[0]
def g(obj):
return obj[item]
else:
def g(obj):
return tuple(obj[item] for item in items)
return g
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.