class MyClass: def __init__( self): print "Initializing..." def __enter__( self): print "Entering..." return self def __exit__( self, type, value, traceback): print "Exiting..." return False # Do not swallow raised exception def Run( self): print "Running" def Main(): with MyClass() as e: e. Run() Main()
No comments:
Post a Comment