[ python-Feature Requests-1726697 ] add operator.fst and snd functions
SourceForge.net
noreply at sourceforge.net
Mon May 28 05:49:31 CEST 2007
Feature Requests item #1726697, was opened at 2007-05-28 03:49
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1726697&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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: paul rubin (phr)
Assigned to: Nobody/Anonymous (nobody)
Summary: add operator.fst and snd functions
Initial Comment:
operator.itemgetter is a general but clumsy abstraction. Almost all the time when I use it, it's either to get the first or the second item of a tuple. I think that use case is common enough that it's worth including them in the operator module:
fst = itemgetter(0)
snd = itemgetter(1)
I end up putting the above definitions in my programs very frequently and it would be nice if I could stop ;)
fst and snd are mathematical names abbreviating "first" and "second" in some areas of math, like sin and cos abbreviate "sine" and "cosine". The names fst and snd are also used in Haskell and *ML. However, calling them "first" and "second" might be stylistically preferable to some Python users and would also be ok.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1726697&group_id=5470
More information about the Python-bugs-list
mailing list