0

https://stackoverflow.com/a/44273861/433570 says 'yield from' is old and we should learn 'await'.
But It doesn't say they are the same thing or they are different.

But I have some good book and videos which talks about yield from

Can I think yield from was replaced by await? and they are essentially the same thing?

https://www.youtube.com/watch?v=MCs5OvhV9S4

I have a book fluent python which also talks about yield from

  • Edit

When I see some good books/videos like the above talking about yield from, could I substitute yield from with await in my mind?

eugene
  • 39,839
  • 68
  • 255
  • 489
  • Does this answer your question? [What does the "yield from" syntax do in asyncio and how is it different from "await"](https://stackoverflow.com/questions/44251045/what-does-the-yield-from-syntax-do-in-asyncio-and-how-is-it-different-from-aw) – testfile Dec 30 '21 at 06:30
  • 1
    @testfile I even quoted the link in my op. It doesn't clearly say they are the same thing whether I can think of `await` as a new name for `yield from` – eugene Dec 30 '21 at 06:41

1 Answers1

0

Yes they are the same thing. Yield is the manual way of doing async await. See https://www.python.org/dev/peps/pep-0492/#new-coroutine-declaration-syntax where they detail that async await is just a coroutine (yield) underneath

testfile
  • 2,145
  • 1
  • 12
  • 31
  • `yield` and `await` may be similar under the hood, but they aren't the same thing, and they're not interchangeable. I had code that wasn't working with `await`, I replaced `await` with `yield` and suddenly the code worked fine. I'm not sure why just that change fixed it, but it has me certain that they aren't "the same thing". – ArtOfWarfare Dec 20 '22 at 03:04