with.connection: Pseudo context-manager for connections

Description Usage Arguments See Also Examples

View source: R/pyfuns.R

Description

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

Usage

1
2
## S3 method for class 'connection'
with(connection, expr)

Arguments

connection

a connection, such as a file connection created with file

expr

expression to evaluate

See Also

with

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
connection <- file("file.csv", "r")

with(connection, {
  print(connection)
})

isOpen(connection)

## End(Not run)

blmoore/pythonistr documentation built on May 20, 2019, 3:34 p.m.