itertools.groupby
Steve Howell
showell30 at yahoo.com
Sun May 27 14:20:34 EDT 2007
--- 7stud <bbxx789_05ss at yahoo.com> wrote:
>
> I'd settle for a simple explanation of what it does
> in python.
>
The groupby function prevents you have from having to
write awkward (and possibly broken) code like this:
group = []
lastKey = None
for item in items:
newKey = item.key()
if newKey == lastKey:
group.append(word)
elif group:
doSomething(group)
group = []
lastKey = newKey
if group:
doSomething(group)
See my other reply for what it actually does in a
simple example.
____________________________________________________________________________________Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
More information about the Python-list
mailing list