Apparently i have found out a way to import functions from one python script to another.
from file_name.py import function_name
But is it possible to transfer variables as well.
Apologies cause I'm new to python.
Apparently i have found out a way to import functions from one python script to another.
from file_name.py import function_name
But is it possible to transfer variables as well.
Apologies cause I'm new to python.
Yes you can import variables too. You can import the variables the same way you import functions.
from file_name import variable_name
The .py
isn't necessary. For the above statement to work the file_name
has to be in the same directory as the file you are working on. Otherwise instead of file_name
you can give the path to the file. i.e C:\User\...\file_name
.
Yeah, there is no problem with that:
from file_name import function_name
print(function_name.variable_name)