aiopen
⚓︎
aiopen
~ Async version of python's built in open -- based on aiofiles
Modules:
-
core
–Async io base functions and utilities
Functions:
-
aiopen
–Async version of the
open
builtin
aiopen
⚓︎
aiopen(
file: PathType,
mode: str = "r",
buffering: int = -1,
encoding: Optional[str] = None,
errors: None = None,
newline: None = None,
closefd: bool = True,
opener: None = None,
*,
loop: Optional[AbstractEventLoop] = None,
executor: Any = None,
) -> AiopenContextManager
Async version of the open
builtin
Examples:
>>> async def main():
... async with aiopen("test.txt", "w") as f:
... await f.write("test")
... async with aiopen("test.txt", "r") as f:
... assert await f.read() == "test"
>>> asyncio.run(main())
>>> import os
>>> if os.path.exists("test.txt"):
... os.remove("test.txt")