Stopiteration identfying the iterable object
<p>I have 2 generator and using the next method &amp; while loop to process thru it as below,</p>

<p>code</p>

<pre><code>while end_of_loop = 'n':
    try:
        table1_row = next(table1_generator)
        table2_row = next(table2_generator)
    except StopIteration:
        end_of_loop = 'y'
</code></pre>

<p>How do I identify which iterator object has no rows?</p>

<p>Im trying to compare 2 tables and each table rows are in generator objects.</p>

<pre><code>def _compare(self):
        end_of_table = 'N'

        try:
            while end_of_table =='N':
                try:
                    if self.table1_key == self.table2_key:
                        print 'same key'
                        self.table1_row = next(self.table1_generator)
                        self._convert_table1_key_fields()
                        self.table2_row = next(self.table2_generator)
                        self._convert_table2_key_fields()
                    elif self.table1_key &gt; self.table2_key:
                        self.table2_row = next(self.table1_generator)
                        self._convert_table2_key_fields()
                    elif self.table1_key &lt; self.table2_key:
                        self.table1_row = next(self.table2_generator)
                        self._convert_table1_key_fields()
                except StopIteration as e:
                    print e.args
                    print 'IterError'
                    end_of_table = 'y'

        except StopIteration:
            print 'Next Iteration'
</code></pre>
