'how to use some variables defined in one fucntion in another function?

I have a function defined as below:

def mod2():
   while true:
       I = raw_results[0]
       Q = raw_results[1]

Now I want to define another function def plot_mod() to plot this I,Q. How can I achieve this?



Solution 1:[1]

You'd pass the I and Q as parameters to the plot_mod() function.

Ignoring the while true:

def mod2():
    I = raw_results[0]
    Q = raw_results[1]
    plot_mod(I, Q)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James McPherson