Lets say FileA and FileB are my two files that do stuff. FileA has as an import FileB has some variables and functions. The Function I want to call in FileA from FileB is X which is using some other variables and functions of FileB. When I try to run the program I get an error saying that "Cannot acces local variable if it's not defined". Now I imagine that it would get all the stuff I declared in FileB but it doesn't. How can I go about this without making my program have a ton of references? Can't I just run my function from FileA while using FileB contents? Note that I am a beginner and it might be a stupid question! And also I will compile the files togheter at the end if it's of any help.
EDIT: If I declare Pas inside my function it does work! But I have too many things to define inside it. Why won't it pick up the context from FileB ?
Example in Code: FileA
import FileB as fb
print(fb.X())
FileB
import random
global Pas
p = "ok"
u = [some randomly generated stuff]
def RandomLetterGen:
some code
Pas = ""
def X():
Pas += RandomLetterGen()
return Pas
This is an easy to understand example but my code does much more to get to the result of the X function in FileB
I tried looking it up online but no luck.