Package schrodinger :: Module project :: Class EmptyIterator
[hide private]
[frames] | no frames]

Class EmptyIterator

Empty iterator. Useful if you have some object that returns an iterator in most cases but in some cases does not. In the "not" case you can return an empty iterator and the calling code can still use a "for i in iterator" form as it will be a no-op.

Instance Methods [hide private]
 
__init__(self)
 
__len__(self)
Needed to allow "if empty_iterator" to evaluate to False.
 
__iter__(self)
Make it possible to iterate without first having to check to see if there is an iterator on which to iterate.
 
next(self)
We never have anything to iterate over.
Method Details [hide private]

__len__(self)
(Length operator)

 

Needed to allow "if empty_iterator" to evaluate to False. Halts the iteration. Can also be used to check to see if the iterator exists or not.

next(self)

 

We never have anything to iterate over. So simply stop iterating.