Clarify why we don't do hasattr(var, '__exit__).

This commit is contained in:
Michael W. Hudson 2004-06-18 11:41:03 +00:00
parent 28e33e4c96
commit c86e93c058
1 changed files with 3 additions and 2 deletions

View File

@ -68,8 +68,9 @@ Basic Syntax and Semantics
finally:
var.__exit__()
Note that this makes using an object that does not have an
__exit__() method a fail-fast error.
(The presence of an __exit__ method is *not* checked like that of
__enter__ to ensure that using inappropriate objects in with:
statements gives an error).
If the variable is omitted, an unnamed object is allocated on the
stack. In that case, the suite has no access to the unnamed object.