Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Yield Keyword
#5
return instead of yield would exit the function and forget about a and b (try it!). yield will return a value while retaining the state of the function in memory until the next time fib() is called. It will therefore remember what a and b were since the last time the function ran.
Reply


Messages In This Thread
Yield Keyword - by 6pathsMadara - Aug-23-2018, 05:43 PM
RE: Yield Keyword - by Larz60+ - Aug-23-2018, 05:59 PM
RE: Yield Keyword - by 6pathsMadara - Aug-23-2018, 06:26 PM
RE: Yield Keyword - by Larz60+ - Aug-23-2018, 08:39 PM
RE: Yield Keyword - by heras - Aug-23-2018, 08:39 PM
RE: Yield Keyword - by DeaD_EyE - Aug-24-2018, 08:30 AM
RE: Yield Keyword - by 6pathsMadara - Aug-24-2018, 11:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  yield from akbarza 4 372 Apr-19-2024, 07:58 PM
Last Post: DeaD_EyE
  yield usage as statement or expression akbarza 5 890 Oct-23-2023, 11:43 AM
Last Post: Gribouillis
  Find a specific keyword after another keyword and change the output sgtmcc 5 893 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Using list comprehension with 'yield' in function tester_V 5 1,325 Apr-02-2023, 06:31 PM
Last Post: tester_V
  Yield generator weird output Vidar567 8 3,341 Nov-23-2020, 10:59 PM
Last Post: deanhystad
  Trying to access next element using Generator(yield) in a Class omm 2 2,024 Oct-19-2020, 03:36 PM
Last Post: omm
  Yield statement question DPaul 6 2,565 Sep-26-2020, 05:18 PM
Last Post: DPaul
  Problem about yield, please help!! cls0724 5 2,920 Apr-08-2020, 05:37 PM
Last Post: deanhystad
  does yield support variable args? Skaperen 0 1,705 Mar-03-2020, 02:44 AM
Last Post: Skaperen
  generator function that yield from a list buran 9 4,311 Jun-04-2019, 10:26 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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