A with method for connection objects which closes the connection after evaluation. This is modelled after the common python idiom.

# S3 method for connection
with(connection, expr)

Arguments

connection

a connection, such as a file connection created with file

expr

expression to evaluate

See also

with

Examples

not_run({ connection <- file("file.csv", "r") with(connection, { print(connection) }) isOpen(connection) })