Top "With-statement" questions

A number of languages have With statements.

Python __enter__ / __exit__ vs __init__ (or __new__) / __del__

I have searched and I'm unable to come up with any good reason to use python's __enter__ /__exit__ rather than __…

python constructor destructor with-statement contextmanager
Is Delphi "with" keyword a bad practice?

I been reading bad things about the with keyword in delphi but, in my opinion, if you don't over use …

delphi with-statement
Is it good practice to depend on python's with...as statement

I'm curious if it is considered safe or good practice to depend on python's with...as statement. For example when …

python with-statement contextmanager
PostgreSQL WITH RECURSIVE performance

I have a simple question. Somehow I was unable to find a definitive answer. How much is WITH RECURSIVE syntax …

database postgresql recursive-query with-statement
SyntaxError: 'with' statements are not valid in strict mode

I'm getting this error in safari console when I try to do anything from a breakpoint. Bug report here: https://…

javascript safari with-statement deprecation-warning
python 'with' statement, should I use contextlib.closing?

from contextlib import closing def init_db(): with closing(connect_db()) as db: with app.open_resource('schema.sql') as …

python with-statement contextmanager
Is it safe to combine 'with' and 'yield' in python?

It's a common idiom in python to use context manager to automatically close files: with open('filename') as my_file: # …

python yield with-statement
Using "with" statement for CSV files in Python

Is it possible to use the with statement directly with CSV files? It seems natural to be able to do …

python csv with-statement
What's the advantage of using 'with .. as' statement in Python?

with open("hello.txt", "wb") as f: f.write("Hello Python!\n") seems to be the same as f = open("…

python with-statement
Alternative to contextlib.nested with variable number of context managers

We have code that invokes a variable number of context managers depending on runtime parameters: from contextlib import nested, contextmanager @…

python deprecated with-statement contextmanager