Skip to content
Myr

Fix a typo in File Opening Behaviors.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Edward G · committed by Edward G · parent e0f59be · Browse files · 1 file+1 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+1 added−4 removed

  • other:+1 added−4 removed

1 file+1 added−4 removed

modified:docs/handling-files.rst+1 added-4 removed
77 unmodified lines
7879File open behavior can be controlled by the boolean kwarg ``lazy``. If a file is opened lazily:8081* A failure at first IO operation will happen by raising an :exc:`FileError`.82* It can help minimize resource handling confusion. If a file is opened in lazy mode, it will receive a83 ``close_intelligently`` method that can help figure out if the file needs closing or not.84 This is not needed for parameters, but is necessary for manually prompting with the :func:`prompt` function as you do not know if a stream like stdout was opened (which was already open85 before) or a real file that needs closing.82* It can help minimize resource handling confusion. If a file is opened in lazy mode, it will receive a ``close_intelligently`` method that can help figure out if the file needs closing or not. This is not needed for parameters, but is necessary for manually prompting. For manual prompts with the :func:`prompt` function you do not know if a stream like stdout was opened (which was already open before) or a real file was opened (that needs closing).8384Since files opened for writing will typically empty the file, the lazy mode should only be disabled if the developer is absolutely sure that this is intended behavior.8586It is also possible to open files in atomic mode by passing ``atomic=True``. In atomic mode, all writes go into a separate file in the same folder, and upon completion, the file will be moved over to the original location. This is useful if a file regularly read by other users is modified.