Python Forum
API-C: call the next value from a generator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
API-C: call the next value from a generator
#1
Hi all,
this is my first post and I hope that I select the right thread.
The following python code is working and I can call it from my C source code (I followed the example provided here: https://docs.python.org/2/extending/embedding.html):
def main:
    rndWP = RndWP(300, 100, 100, 10, 100, 0)
    x =rndWP.NextPlese()
    return x
RndWP is a class which create a generator: the constructor set all parameters (300, 100, ...) while "NextPlease" is the function of the class which extracts the new value.

Now the problem is that I would like to call NextPlease function from my C code and get the new number from the generator. Right now my C code is able to run the "main" function and get the first number. Ho can I get the second number, the third number and so on?

I'm using python 2.7 due to compatibility problem with the generator (that is, I cannot switch to python3).

Any suggestion is more than welcome.

Thanks,
M
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  list call problem in generator function using iteration and recursive calls postta 1 1,889 Oct-24-2020, 09:33 PM
Last Post: bowlofred
  receive from a generator, send to a generator Skaperen 9 5,495 Feb-05-2018, 06:26 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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