Iterator over class objects
<p>I have a DbData class which has a first and next method. It wraps a C API. These methods throw an exception if their is no first or next item to get.</p>

<p>I then have two classes called Product and Customer which create DbData objects in their constructors as follows:</p>

<pre><code>class Products:
    def __init__(self, db):
        self.db = db
        self.data = self.db.create_data(DB_PRODUCT)

    def __enter__(self):
        return self

    def __exit__(self, *exc):
        self.db.delete_data(self.data)
        return False
    ...

class Customers:
    def __init__(self, db):
        self.db = db
        self.data = self.db.create_data(DB_CUSTOMER)
    ...
</code></pre>

<p>So a call to self.db.first(self.data) populates self.data with data for the first item, if it exists. How might I add python style iterators to these classes so as to iterate over all items? </p>
