Passing data to functions in different modules (not explicitly)

28 views Asked by At

My problem can be generalized by this example. I have a Jupter notebookfile, say main. ipynb and I am calling some functions which are in a different notebook that I wrote.

#File name main.ipynb

Bunch of code and variable assignment of x,y,z and create arrays a,b,c

# Function call 

some_function(x,y,z):
    #Do bunch of operations on x,y,z and a,b,c but a,b,c are not passed to the function
    return result

My main notebook finds variables x,y,z but in addition also creates arrays a,b and c. These arrays are not passed to the function but are required by the function 'some_function' to run the code.

For reasons I wont go into, I can't also pass the arrays a,b and c.

What's the easiest way to make some_function in the other notebook aware of arrays a,b and c which are generated in my main notebook?

Am I better off not using notebooks and just .py files? What are the pros/cons of either? Any help is appreciated, thanks!

0

There are 0 answers