-
This is in reference to the examples in the documentation e.g. https://gemmi.readthedocs.io/en/latest/cif.html#python. Is there a way to close files after they are opened that is not documented? I've browsed the source code and see that the Python wrappers directly reference the C++, which has no explicit file closing method. The danger is that it is likely to end up with too many opened handles. Kindly assist. Paul K |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I propose that the best way to handle this is to use the from gemmi import cif
with open("file.star") as f:
doc = cif.read_string(f.read()) which guarantees that the file will be closed. |
Beta Was this translation helpful? Give feedback.
-
The functions in Python bindings that are reading files, they open a file, read the content, and close the file. They should be more efficient than reading the file as string in Python. |
Beta Was this translation helpful? Give feedback.
The functions in Python bindings that are reading files, they open a file, read the content, and close the file. They should be more efficient than reading the file as string in Python.