In Matlab I can write a program that calls a sub-function which is saved to an external file. In that sub-function I can use variables without declaring them locally as long as they have been defined globally before. Is that kind of behaviour possible in python too?
An example would be a sub-function that should plot something. Currently I'm passing numpy (np) and matplotlib (plt) as an argument to that function
def plot_weights(weights,session,np,plt):
...
The example above comes from a tensorflow tutorial, so session
stands for a tensorflow session.
Is it possible to define a function like this
def plot_weights(weights):
...
and make python take session
, np
, plt
as some global variables?