Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yield statement question
#3
One use case is for generators that allow you to create potentially infinite sequences. Obviously, you can't store such things in memory, so this technique allows you to compute the next value on demand as you iterate. The idea is called "lazy evaluation" in general.
Reply


Messages In This Thread
Yield statement question - by DPaul - Sep-26-2020, 08:12 AM
RE: Yield statement question - by Gribouillis - Sep-26-2020, 11:43 AM
RE: Yield statement question - by ndc85430 - Sep-26-2020, 11:59 AM
RE: Yield statement question - by DPaul - Sep-26-2020, 02:45 PM
RE: Yield statement question - by Gribouillis - Sep-26-2020, 03:00 PM
RE: Yield statement question - by DPaul - Sep-26-2020, 05:18 PM
RE: Yield statement question - by perfringo - Sep-26-2020, 04:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  yield from akbarza 4 512 Apr-19-2024, 07:58 PM
Last Post: DeaD_EyE
  question of using not in if statement and .. akbarza 3 569 Feb-29-2024, 08:40 AM
Last Post: Gribouillis
  yield usage as statement or expression akbarza 5 1,001 Oct-23-2023, 11:43 AM
Last Post: Gribouillis
  Using list comprehension with 'yield' in function tester_V 5 1,478 Apr-02-2023, 06:31 PM
Last Post: tester_V
  Yield generator weird output Vidar567 8 3,430 Nov-23-2020, 10:59 PM
Last Post: deanhystad
  Trying to access next element using Generator(yield) in a Class omm 2 2,101 Oct-19-2020, 03:36 PM
Last Post: omm
  Problem about yield, please help!! cls0724 5 3,035 Apr-08-2020, 05:37 PM
Last Post: deanhystad
  does yield support variable args? Skaperen 0 1,735 Mar-03-2020, 02:44 AM
Last Post: Skaperen
  generator function that yield from a list buran 9 4,436 Jun-04-2019, 10:26 PM
Last Post: snippsat
  yield help chakox 5 3,417 Apr-13-2019, 09:42 PM
Last Post: chakox

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020