# L-21.0 MCS 260 Mon 4 Aug 2014 : show_yield.py

"""
Illustration of the use of a generator with yield.
"""

def counter(value=0):
    """
    Maintains a counter.
    """
    count = value
    while True:
        count = count + 1
        yield count

def main():
    """
    Example of the use of a generator.
    """
    print 'initializing counter ...'
    mycounter = counter(3)
    print 'incrementing counter ...'
    print mycounter.next()
    print 'incrementing counter ...'
    print mycounter.next()

if __name__ == "__main__":
    main()
