A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-March/147580.html below:

[Python-Dev] iscoroutinefunction vs. coroutines

[Python-Dev] iscoroutinefunction vs. coroutines [Python-Dev] iscoroutinefunction vs. coroutinesMatthias Urlichs smurf at noris.de
Thu Mar 9 06:04:40 EST 2017
Hi,

Is this pattern

	def foo():
		return bar()
	async def bar():
		await <whatever>

	async def async_main():
		await foo()

considered to be valid?

The reason I'm asking is that some code out there likes to accept a
might-be-a-coroutine-function argument, using

	def run_callback(fn):
		if iscoroutinefunction(fn):
			res = await fn()
		else:
			res = fn()

instead of

	def run_callback(fn):
		res = fn()
		if iscoroutine(res):
			res = await res()

The former obviously breaks when somebody combines these idioms and calls

	run_callback(foo)

but I can't help but wonder whether the latter use might be deprecated, or
even warned about, in the future and/or with non-CPython implementations.

-- 
-- Matthias Urlichs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170309/fc10ec40/attachment.sig>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4