[Patches] [ python-Patches-1660179 ] functools.compose to chain functions together

SourceForge.net noreply at sourceforge.net
Thu Feb 15 01:17:07 CET 2007


Patches item #1660179, was opened at 2007-02-14 19:17
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1660179&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Chris AtLee (catlee)
Assigned to: Nobody/Anonymous (nobody)
Summary: functools.compose to chain functions together

Initial Comment:
The motivation for this patch was to be able to chain together operator.itemgetter objects so that I could sort a list of items that have the form ((a,b), c) by the 'a' or 'b' part of the item.

Sorting by 'b' can be accomplished with:
l.sort(key=compose(itemgetter(1), itemgetter(0)))

compose(itemgetter(1), itemgetter(0)) is equivalent to

def c(v):
    return itemgetter(1)(itemgetter(0)(v))

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1660179&group_id=5470


More information about the Patches mailing list