diff options
| author | Rapptz <[email protected]> | 2018-06-10 18:09:14 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2018-06-10 18:10:00 -0400 |
| commit | f25091efe1281aebe70189c61f9cac405b21a72f (patch) | |
| tree | d0d13dad1a89de9f45845a36ea475098b7a0b494 /docs/api.rst | |
| parent | Add Message.jump_to_url (diff) | |
| download | discord.py-f25091efe1281aebe70189c61f9cac405b21a72f.tar.xz discord.py-f25091efe1281aebe70189c61f9cac405b21a72f.zip | |
Drop support for Python 3.4 and make minimum version 3.5.2.
Diffstat (limited to 'docs/api.rst')
| -rw-r--r-- | docs/api.rst | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/docs/api.rst b/docs/api.rst index 8be772ac..109f78f9 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -93,17 +93,8 @@ to handle it, which defaults to print a traceback and ignoring the exception. .. warning:: All the events must be a |corourl|_. If they aren't, then you might get unexpected - errors. In order to turn a function into a coroutine they must either be ``async def`` - functions or in 3.4 decorated with :func:`asyncio.coroutine`. - - The following two functions are examples of coroutine functions: :: - - async def on_ready(): - pass - - @asyncio.coroutine - def on_ready(): - pass + errors. In order to turn a function into a coroutine they must be ``async def`` + functions. .. function:: on_connect() @@ -1306,22 +1297,11 @@ Some API functions return an "async iterator". An async iterator is something th capable of being used in an `async for <https://docs.python.org/3/reference/compound_stmts.html#the-async-for-statement>`_ statement. -These async iterators can be used as follows in 3.5 or higher: :: +These async iterators can be used as follows: :: async for elem in channel.history(): # do stuff with elem here -If you are using 3.4 however, you will have to use the more verbose way: :: - - iterator = channel.history() # or whatever returns an async iterator - while True: - try: - item = yield from iterator.next() - except discord.NoMoreItems: - break - - # do stuff with item here - Certain utilities make working with async iterators easier, detailed below. .. class:: AsyncIterator |