Reputation: 25
I'm trying to make a python library and I need to pass the variable x
to the main document.
external.py
:
def get_x():
x = '123'
main.py
:
import external
external.get_x()
print(x)
This ofcourse wouldn't work as x
is not defined in main.py
, right?
Upvotes: 1
Views: 149
Reputation: 184
external.py:
def get_x():
x = '123'
return x
main.py:
import external
x=external.get_x()
print(x)
Upvotes: 2