![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveRe: best way to determine sequence ordering?
From: Steven Bethard <steven.bethard@gmail.com>
Date: Sun Apr 30 2006 - 02:37:20 CEST
John Salerno wrote:
Ok, since, as happens some times, the discussion here has gotten
* The original::
if L.index('A') < L.index('D'):
If you're doing exactly one comparison, this is probably your best
* Justin Azoff's before()::
def before(lst, a, b):
if before(L, 'A', 'D'):
You might gain a bit from this version if one of the elements you're
* building a dict of indicies::
positions = dict((item, i) for i, item in enumerate(L))
if positions['A'] < positions['D']:
You'll only get a gain from this version if you need to do several
And most importantly, as Edward Elliot put it:
Remember kids:
HTH,
STeVe
|