Search code examples
pythonvizard

Return output from function called from a function


I'm using Vizard (Python) and would like to have an event that runs every time the clock is updated. The function to do this properly in Vizard is vizact.ontimer(). The manual for this function can be found here.

The function I'd like to call has both inputs and outputs. I understand that (according to the vizact.ontimer() function manual) I can specify inputs to the function as follows:

vizact.ontimer(0,myFunction,inputs)

...Where inputs is a list of inputs, and myFunction is the name of the function I'd like to run. The 0 simply means that the function should run whenever it gets a chance.

However, I don't know how I can catch the outputs from myFunction. How do I do this? It seems that the vizact.ontimer() function returns an object that bears no resemblance to the output of myFunction.


Solution

  • The docs dosent seem to specify a way to do this. You could simply work around by passing a list to the function through the args, and have the function append its needed outputs to that list.

    EXAMPLE:

    >>> def a(x):
        x.append('0')
    
    
    >>> b = [1,2,3]
    >>> a(b)
    >>> b
    [1, 2, 3, '0']