>'with' [ var '=' ] expr ':' > suite > > This statement is defined as being equivalent to the following > sequence of statements: > >var = expr > >if hasattr(var, "__enter__"): > var.__enter__() > >try: > suite > >finally: > if hasattr(var, "__exit__"): >var.__exit__() > > 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. I would not really depend when var is specified, that its binding is not modified in suite, I would store expr result away and use that: var = _secret = expr ... rest of impl uses _secret not var ... Less fragile. regards
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