Skip to content

implement context management with the with keyword  #94

@zshaheen

Description

@zshaheen

I think cdms should support context management with the with keyword. So the idea is to have something similar to how files are handled in Python:

with cdms2.open('precc.nc') as precc_file:
   var = precc_file('PRECC')

This automatically has exception handling and automatically closes the file after leaving the scope. All that is needed is to implement __enter__() and __exit__() functions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions