Package CHEM :: Package Common :: Module IteratorFactory :: Class IteratorFactory
[hide private]
[frames] | no frames]

Class IteratorFactory



Abstract base class for all iterator factories. Given a collection of objects in some form, instances of this class should be able to produce (as a factory) fresh iterators over the collection.

Of particular importance is that multiple iterator instances should be able to exist simultaneously and at different positions to enable nested looping over the same collection.

It effectively encapsulates a streaming data source (such as a file) as if it were an in-memory list that you could keep retrieving fresh iterators off of.

Instance Methods [hide private]
 
__iter__(self)
Primary abstract method where, that returns an iterator useable in a "for item in iterator:" construct.
Method Details [hide private]

__iter__(self)

 
Primary abstract method where, that returns
an iterator useable in a "for item in iterator:" construct.
Based on the "iterable" interface, so no explicit function
call is needed.  If you want to though, you could do something like

factory = FileFactory(filename);
for item in iter(factory):
    print item;

or just

for item in factory:
    print item;