Skip to content

Include in the samples how to write to open files like stdout  #131

Closed
@dougransom

Description

please include in the docs how to write to stdout. here is a snippent of how i did it , wrap isn't documented.

`import asyncio
from email import contentmanager
import aiohttp
import aiofiles
from aiofiles.os import wrap
import sys
import os

aio_write = aiofiles.os.wrap(os.write)

async def main():
async with aiofiles.open("sample.txt") as f:
#contents=await f.read()
write_stdout=wrap(sys.stdout.write)
print_stdout=wrap(print)

    async for contents in f:
        await write_stdout(contents)
        #await  print_stdout(f"stdout test")

asyncio.run(main())`

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions