Mailing List Archive

[ python-Feature Requests-1726697 ] add operator.fst and snd functions
Feature Requests item #1726697, was opened at 2007-05-27 22:49
Message generated for change (Settings changed) made by rhettinger
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: Closed
>Resolution: Rejected
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.


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

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-05-27 23:49

Message:
Logged In: YES
user_id=80475
Originator: NO

-1

That would provide too many ways to do it.
It is more important to learn how to use one way correctly.


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

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1726697&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com