# L-41 MCS 260 Fri 22 Apr 2016 : 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(next(mycounter))
    print('incrementing counter ...')
    print(next(mycounter))

if __name__ == "__main__":
    main()
