Às 19:42 de 21/04/19, Stefan Ram escreveu: > Paulo da Silva writes: >> I have a list of objects and want to split it in a list of groups. >> "equal objects" is based on an id we can get from the object. > > main.py > > input = [ 'abc', 'ade', 'bcd' ] > > for group, list in \ > __import__( 'itertools' ).groupby( input, lambda x: x[ 0 ] ): > print( group, *list ) >
Yes, seems to be the best way to go. I need to sort data first, however. Thanks -- https://mail.python.org/mailman/listinfo/python-list