Top "With-statement" questions

A number of languages have With statements.

With... End With vs Using in VB.NET

I just found out that like C#, VB.NET also has the using keyword. Until now I thought it didn't …

vb.net scope idisposable using-statement with-statement
pass argument to __enter__

Just learning about with statements especially from this article question is, can I pass an argument to __enter__? I have …

python with-statement
RAII in Python - automatic destruction when leaving a scope

I've been trying to find RAII in Python. Resource Allocation Is Initialization is a pattern in C++ whereby an object …

python scope raii with-statement
Context manager for Python's MySQLdb

I am used to (spoiled by?) python's SQLite interface to deal with SQL databases. One nice feature in python's SQLite's …

python mysql with-statement contextmanager
Scope of variable within "with" statement?

I am reading only firstline from python using : with open(file_path, 'r') as f: my_count = f.readline() print(…

python scope with-statement
Conditional with statement in Python

Is there a way to begin a block of code with a with statement, but conditionally? Something like: if needs_…

python conditional indentation conditional-statements with-statement
Python multi-line with statement

What is a clean way to create a multi-line with in python? I want to open up several files inside …

python python-3.x multiline with-statement
Python nested context manager on multiple lines

In Python 2.6, we used to format our nested context manager that way: with nested( context1, context2 ) as a, b: pass …

python with-statement contextmanager
Using WITH clause with INSERT statement in POSTGRESQL

I have a requirement in which I need to get one column from another table and insert that column data …

postgresql with-statement insert-into
Nesting 'WITH' statements in Python

It turns out that "with" is a funny word to search for on the internet. Does anyone knows what the …

python append with-statement