itertools.groupby
Steve Howell
showell30 at yahoo.com
Sun May 27 13:57:29 EDT 2007
--- 7stud <bbxx789_05ss at yahoo.com> wrote:
> Bejeezus. The description of groupby in the docs is
> a poster child
> for why the docs need user comments.
I would suggest an example with a little more
concreteness than what's currently there.
For example, this code...
import itertools
syslog_messages = [
'out of file descriptors',
'out of file descriptors',
'unexpected access',
'out of file descriptors',
]
for message, messages in
itertools.groupby(syslog_messages):
print message, len(list(messages))
...produces this...
out of file descriptors 2
unexpected access 1
out of file descriptors 1
____________________________________________________________________________________Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
More information about the Python-list
mailing list