On 4/24/06, Aahz <aahz at pythoncraft.com> wrote: > Let's go back to a pseudo-coded with statement: > > with EXPRESSION [as NAME]: > BLOCK > > What happens while BLOCK is being executed? Again, here's what I said > originally: > > EXPRESSION returns a value that the with statement uses to create a > context (a special kind of namespace). The context is used to > execute the BLOCK. The block might end normally, get terminated by > a break or return, or raise an exception. No matter which of those > things happens, the context contains code to clean up after the > block. I strongly object to your use of the term "namespace" here. The with statement does *not* create a new namespace. Using the term namespace will only confuse people who understand what it means (in Python) -- we have the global namespace, the builtin namespace, the local namespace, classes introduce a new namespace, etc. The with-statement does *not* create a namespace in this sense -- there's no new place where name lookup can take place. In particular, this code prints 42: x = 1 with whatever(doesnt_matter): x = 42 print x -- --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4