itertools.groupby
- From: 7stud <bbxx789_05ss@xxxxxxxxx>
- Date: 27 May 2007 10:17:52 -0700
Bejeezus. The description of groupby in the docs is a poster child
for why the docs need user comments. Can someone explain to me in
what sense the name 'uniquekeys' is used this example:
import itertools
mylist = ['a', 1, 'b', 2, 3, 'c']
def isString(x):
s = str(x)
if s == x:
return True
else:
return False
uniquekeys = []
groups = []
for k, g in itertools.groupby(mylist, isString):
uniquekeys.append(k)
groups.append(list(g))
print uniquekeys
print groups
--output:--
[True, False, True, False, True]
[['a'], [1], ['b'], [2, 3], ['c']]
.
- Follow-Ups:
- Re: itertools.groupby
- From: Gordon Airporte
- Re: itertools.groupby
- From: Carsten Haese
- Re: itertools.groupby
- From: Steve Howell
- Re: itertools.groupby
- From: Steve Howell
- Re: itertools.groupby
- Prev by Date: Re: ten small Python programs
- Next by Date: Re: itertools.groupby
- Previous by thread: [ANN] argparse 0.8 - Command-line parsing library
- Next by thread: Re: itertools.groupby
- Index(es):