Skip to main content

Diigo Home

10.9. operator - Standard operators as functions - Python v2.7a0 documentation - The Diigo Meta page

docs.python.org/...operator.html - Cached - Annotated View

Benx Shen's personal annotations on this page

benxshen
Benxshen bookmarked on 2009-10-20 python code snippets
  • 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.

  • 20 Oct 09
    • 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