[code.view]

[top] / python / PyMOTW / exceptions / exceptions_GeneratorExit.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2008 Doug Hellmann All rights reserved.
     #
     """
     """
     
     __version__ = "$Id$"
     #end_pymotw_header
     
     def my_generator():
         try:
             for i in range(5):
                 print 'Yielding', i
                 yield i
         except GeneratorExit:
             print 'Exiting early'
     
     g = my_generator()
     print g.next()
     g.close()
     

[top] / python / PyMOTW / exceptions / exceptions_GeneratorExit.py

contact | logmethods.com