tuples, index method, Python's design

Carsten Haese carsten at uniqsys.com
Sun Apr 8 05:59:48 CEST 2007


On Sun, 08 Apr 2007 02:40:52 GMT, Alan Isaac wrote
> "Carsten Haese" <carsten at uniqsys.com> wrote in message
> news:mailman.6146.1175956040.32031.python-list at python.org...
> > Adding useless features always makes a product worse. What's your use
> > case for tuple.index?
> [...] consider a game,
> where the fixed set p of players have a fixed order.
> A tuple is natural.  Now for a player you want to
> construct the opponents.  If I had the index i it wd
> be p[:i]+p[i+1:], but how to get the index?

opponents = tuple(x for x in p if x is not current_player)

-Carsten




More information about the Python-list mailing list