What I’m trying to do:
I’m in the early development stage of an app and playing with different modules/structures. I have some server models which I’d like ready access to for copying and pasting code without leaving the Anvil editor and I want to prevent them from being imported at run-time.
What I’ve tried and what’s not working:
Of course I could have the reference code in another editor like VS-code but also want to share this project with collaborators.
Likewise creating another Git branch to make the reference modules appear/disappear is very cumbersome and not worth the effort.
I’ve tried putting quit() as the first line in unwanted server modules but this raises a SystemExit error that prevents further modules from importing.
I’ve tried creating a dummy server Package _DO_NOT_IMPORT
and moving the reference modules underneath it, but Anvil is ironically too helpful and finds them anyway! called from _DO_NOT_IMPORT._BIGPST, line 1
The modules in question will run some lines even if I use the normal if __name__ == "__main__"
block because they’re not self containted in class
or def
statements.
Sorry if this is more of a general Python question about modules vs packages vs imports rather than Anvil specific.
Code Sample:
In the example below I don’t want _BIGPST or the other two modules below it to run or be imported