Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
yield help
#5
chakox Wrote:i don't understand why the other method work only in the interpreter.
When you run code in the interactive interpreter, it prints the result of every statement (if not None). In this case, it prints the result of gen2.send(58), which is the next value produced by yield. In a file you don't see the result because there is no call to print(). Consider this
>>> x = y = 1
>>> x + y
2
The same code in a file doesn't display the 2.
Reply


Messages In This Thread
yield help - by chakox - Apr-11-2019, 11:28 PM
RE: yield help - by perfringo - Apr-12-2019, 06:24 AM
RE: yield help - by Gribouillis - Apr-12-2019, 07:02 AM
RE: yield help - by chakox - Apr-13-2019, 09:00 PM
RE: yield help - by Gribouillis - Apr-13-2019, 09:26 PM
RE: yield help - by chakox - Apr-13-2019, 09:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  yield from akbarza 4 284 Apr-19-2024, 07:58 PM
Last Post: DeaD_EyE
  yield usage as statement or expression akbarza 5 815 Oct-23-2023, 11:43 AM
Last Post: Gribouillis
  Using list comprehension with 'yield' in function tester_V 5 1,261 Apr-02-2023, 06:31 PM
Last Post: tester_V
  Yield generator weird output Vidar567 8 3,296 Nov-23-2020, 10:59 PM
Last Post: deanhystad
  Trying to access next element using Generator(yield) in a Class omm 2 1,982 Oct-19-2020, 03:36 PM
Last Post: omm
  Yield statement question DPaul 6 2,527 Sep-26-2020, 05:18 PM
Last Post: DPaul
  Problem about yield, please help!! cls0724 5 2,876 Apr-08-2020, 05:37 PM
Last Post: deanhystad
  does yield support variable args? Skaperen 0 1,688 Mar-03-2020, 02:44 AM
Last Post: Skaperen
  generator function that yield from a list buran 9 4,195 Jun-04-2019, 10:26 PM
Last Post: snippsat
  Multiple calls to Python interpreter embedded in C++ application yield segmentation f mmoelle1 0 2,840 Mar-21-2019, 08:54 PM
Last Post: mmoelle1

Forum Jump:

User Panel Messages

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