itertools.groupby

Steve Howell showell30 at yahoo.com
Sun May 27 17:59:43 EDT 2007


--- Carsten Haese <carsten at uniqsys.com> wrote:

> On Sun, 2007-05-27 at 10:17 -0700, 7stud wrote:
> > 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']]
> 
> The so-called example you're quoting from the docs
> is not an actual
> example of using itertools.groupby [...]

Huh?  How is code that uses itertools.groupby not an
actual example of using itertools.groupby?

These docs need work.  Please do not defend them;
please suggest improvements.




       
____________________________________________________________________________________Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC



More information about the Python-list mailing list