How to group a list of tuples/objects by similar index/attribute in python?
<p>Given a list</p>

<pre><code>old_list = [obj_1, obj_2, obj_3, ...]
</code></pre>

<p>I want to create a list:</p>

<pre><code>new_list = [[obj_1, obj_2], [obj_3], ...]
</code></pre>

<p>where <code>obj_1.some_attr == obj_2.some_attr</code>.</p>

<p>I could throw some <code>for</code> loops and <code>if</code> checks together, but this is ugly. Is ther a pythonic way for this? by the way, the attributes of the objects are all strings.</p>

<p><strong>Alternatively a solution for a list containing tuples (of the same length) instead of objects is appreciated, too.</strong></p>
