I may be overthinking this, so could use some insight.
I have my Python code set up as follows:
(…couple of levels down from root (\))
|----->_System Software (dir)
|---------->FreqCntr_Sys.pyw
|---------------->FreqCntrFuncts (dir)
|---------------------->__pycache__ (dir)
|---------------------->__init__.py
|---------------------->FCSystemText.pyw
|---------------------->. (a number of other Python files)
(NOTE: I assume the __pycache__ dir with a number of .pyc files, is where the “compiled” code of my Python files is kept)
In my main program file (FreqCntr_Sys.pyw) before any class or def declarations I have
from FreqCntrFuncts.FCSystemText.pyw import *
FCSystemText.pyw contains text, variable and constant declarations (no methods or functions) as a means to keep all my declarations in one place (kind of the equivalent of “include” in an assembler file). I also have “global” statements in any methods or functions that need access to these global definitions.
Unfortunately, this doesn’t seem to be working. When my program tries to access a variable or constant that I believe should have been imported, I get a
NameError: name '<varname>' is not defined
I read on another forum ((stackflow?) that I could check for a valid import with the following code
from FreqCntrFuncts.FCSystemText import *
if "FreqCntrFuncts.FCSystemText" not in dir():
print("FCSystemText not imported!")
and the result I get is:
FCSystemText not imported!
However, if I place the explicit declaration in my main file (right after the other “import” statements), the error does not happen.
To clarify (and, hopefully, not make things more muddy all I’m looking to do is import the file as text, if that makes sense or is possible with how Python operates. As I mentioned above, I’m thinking it might be like an “include <filename>” in assembler language. The include simply replaces the include statement with the text contents of the file. No preprocessing takes place (since an assembler operates more like a compiler). Can/does Python operate that way?
I expect I’m missing something fairly straightforward about this.
Help and insight appreciated, as usual
Thx and cheers…