Tinche / aiofiles

File support for asyncio
Apache License 2.0
2.67k stars 149 forks source link

`async with` throws error #38

Closed ek-nath closed 6 years ago

ek-nath commented 6 years ago
import aiofiles
print(aiofiles.__version__)

async with aiofiles.open('wctDA2.tmp', mode='r') as f:
    contents = await f.read()
print(contents)

Output:


File "a.py", line 4
    async with aiofiles.open('wctDA2.tmp', mode='r') as f:
             ^
SyntaxError: invalid syntax

Details:

  1. python: Python 3.6.4 :: Anaconda custom (64-bit)
  2. OS: Windows 10 x64
  3. aiofiles: 0.3.2
Dobatymo commented 6 years ago

You can only have "async with" within "async def".

ek-nath commented 6 years ago

That's just dumb of me. Sorry and thank you.