As I'm new to the python world, I'm asking you today about the best way to use another python file's functions.
Let's take this example:
- app/
- __init__.py
- helpers/
- __init__.py
- myhelper.py
- run.py
run.py
import app
app.setname("helloworld")
app.run()
app/__init__.py
def setname(fname):
global name
name = fname
def run():
import helpers.myhelper as my_helper
my_helper.function()
app/helpers/myhelper.py
from .. import name
def function:
return "hello world ! "+name
My question: Is it clear to use an import in the middle of a function, as I can't use it at the top?
Is it a good way to use a global variable like this? As you know I have multiple global variables in my case etc and this is how I made things.
Any suggestions?