Can a python module read variables from the main program -


i started learning python, , language. have quick question i'm hoping can answer (forgive stupidity, still learning python). how can program module read variables program imported it? if example.py says

import mymodule     example = raw_input(' example ') 

how can how can program mymodule read value of example?

does not require programming, and, in mymodule's source can type

print (example) 

or there code have use module can value of variable in program imported it?

p.s. brand new python, , first stackoverflow post, please forgive stupidity on no doubt simple question. thanks!!

the functions in module should able take in arguments. can pass example variable parameter.

e.g in mymodule.py:

def foo(x):     print(x) 

in example.py:

import mymodule     example = raw_input(' example ') mymodule.foo(example) 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -