New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement context management with the `with` keyword #94

Closed
zshaheen opened this Issue Feb 21, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@zshaheen
Member

zshaheen commented Feb 21, 2017

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.

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Apr 24, 2017

should be fixed by #121

@doutriaux1 doutriaux1 closed this Apr 25, 2017

@doutriaux1 doutriaux1 modified the milestone: 2.10 May 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment