Using Yield in Panda

Hi all,

I didn’t manage to use the yield statement, it provoked this error:

with this code:

    def camTask_fixCenter(self,task):
        """Simple center fixing task"""
        while task.time-self.lct<self.tlt:
            print p,
            yield Task.cont
        print "change"
        yield Task.done

I wondered if it was a possible thing that could be added, (if not already possible).

Thanks for your comments!

Sounds like a spiffy feature for the wishlist. Seems possible to add it in theory, and it wouldn’t be very difficult. However, since we’re not using Python 2.4 yet in the VR Studio, we can’t use or add this feature (yield wasn’t added until Python 2.5). That doesn’t mean someone else couldn’t add it instead.

If nothing else, you could do this by writing an intermediate task function that called your own generator function repeatedly. This would be a very simple function and it should be easy to write.


i dont understand why you want to use yield. A task is only called once a frame and there is currently no way to change that behaviour. Can you explain why you would want such a implementation? (im just wondering what you think, this could be used for)

Hypnos, yield is a continuation + a generator. Its very cool as you see he can use it inside a for loop and it start up again inside a for loop.

I do understand what yield is used for (although im not used to use it). but i cant see any sense in using it in this case. Because if it’s a task you can’t control the loop mechanism the function is called.

maybe i understand what i am missing, the yield will continue where it was left when it exited? (just thinking loud, but i think i get it)

yeah so you can start a big complex task and add yeild at random points and the task will restart at the same state again. Thats actually a pretty cool idea! I might do it for my game. It might get a little cleaner because python would keep that state of the task for me.


Just think of how powerful this might be… I’ll try in my free time to write this little thing.
I’ll repost when it will be done! :smiley: