<filename>pep343.py<gh_stars>0


with EXPR as VAR:
    BLOCK
	
# Same as

mgr = (EXPR)
exit = type(mgr).__exit__  # Not calling it yet
value = type(mgr).__enter__(mgr)
exc = True
try:
    try:
	    VAR = value # Only if "as VAR" is present
		
		BLOCK
	except:
	    # The exceptionall case is handleed here
		exc = FALSE
		if not exit(mgr, *sys.exc_info()):
		    raise
		# The exception is swallowed if exit() returns true
finally:
    # The normal and non-local-goto cases are handled here
	if exc:
	    exit(mgr, None, None, None)
		
		
		
<filename>pep343.py<gh_stars>0


with EXPR as VAR:
    BLOCK
	
# Same as

mgr = (EXPR)
exit = type(mgr).__exit__  # Not calling it yet
value = type(mgr).__enter__(mgr)
exc = True
try:
    try:
	    VAR = value # Only if "as VAR" is present
		
		BLOCK
	except:
	    # The exceptionall case is handleed here
		exc = FALSE
		if not exit(mgr, *sys.exc_info()):
		    raise
		# The exception is swallowed if exit() returns true
finally:
    # The normal and non-local-goto cases are handled here
	if exc:
	    exit(mgr, None, None, None)
		
		
		
# Same as # Not calling it yet # Only if "as VAR" is present # The exceptionall case is handleed here # The exception is swallowed if exit() returns true # The normal and non-local-goto cases are handled here