Calling an async def Function

async def greet(name):
    print(f"hello, {name}")
    return name.upper()

result = greet("ada")
print(type(result))

What does running this print?

A

It raises RuntimeError: coroutine functions must be called with await, because Python refuses to construct a coroutine object outside of a running event loop.

B

<class 'coroutine'>, and nothing else. Calling greet("ada") does not run the function body at all, it only creates a coroutine object, so "hello, ada" never prints unless that object is awaited or scheduled on an event loop.

C

hello, ada <class 'str'>, because calling an async def function runs it synchronously up to its first await, and since there is no await here, it runs to completion.

D

hello, ada <class 'coroutine'>, because the function body runs immediately on call, but the return value still gets wrapped in a coroutine object.