This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add operator.fst and snd functions
Type: enhancement Stage:
Components: None Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: phr, rhettinger
Priority: normal Keywords:

Created on 2007-05-28 03:49 by phr, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg55129 - (view) Author: paul rubin (phr) Date: 2007-05-28 03:49
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.
msg55130 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-05-28 04:49
-1

That would provide too many ways to do it.  
It is more important to learn how to use one way correctly.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45008
2007-05-28 03:49:31phrcreate