i'm a beginner with Python and want to write a programm where i have a main program and several subprograms.
The problem i have is the following:
import func_betriebssysteme
func_betriebssysteme.betriebssystem()
# Schritt 1
print("Betriebssystem:",betriebssystem_use)
That is the code of "func_betriebssysteme", my separat py.file:
def betriebssystem():
import sys
temp_a = sys.platform
global betriebssystem_use
betriebssystem_use = str(temp_a)
And that is the errormessage:
--------------------------------------------------------------------------- NameError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_6860/1431564812.py in () 9 # Schritt 1 10 ---> 11 print("Betriebssystem:",betriebssystem_use) NameError: name 'betriebssystem_use' is not defined
If i have the function betriebssystem() directly at the beginning of the code and not in a separat file, it works.
What do i do wrong?
Edit 21.3.2023
Hello again,
I haven't really made any progress yet.
I'm still feeling my way along, bit by bit. In the process, I noticed the following.
When I run this code, I get a name error bsuse not defined.
from func_ausschr.func_betriebssysteme import *
betriebssystem()
print(bsuse)
That is the code in the file func_auschr.func_betriebssysteme
def betriebssystem():
import sys
global bsuse
temp = sys.platform
bsuse = temp
If I run the code again directly, the variable is resolved with win32.
What is going wrong here?
By the way, I use Python3.10 in Jupyter-Notebook (Visual Studio Code) for testing.