I’ve got a python script, which should read a subdirectory and make all the scripts within it callable like this:
I’ve figured out most of the details but I’m having a loterijlot of trouble determining on how to uitvoer an API (object or selected functions) to subscript s that mainscript imports. The intention is for the subscript s to work spil pluggable guidelines to mainscript (te other words, there is no need for them to work stand-alone).
Things I’ve attempted, that I think would be stijlvol enough are (after invoer subdirectory.subscript ter mainscript ):
Related movie: Did My Gemini Account Get Hacked?
which works, but gives my subscript access to everything unconditionally and will likely be a source of horrible bugs if this is to be used by others.
from __main__ invoer *
which doesn’t work despite defining __all__ to include the name api at the end of mainscript (I just get told that name ‘api’ is not defined when I attempt to reference the object I want).
Related movie: Brink Hacked… Vereiste Own Bcash?
from __main__ invoer api
Related movie: How To Trade Crypto Volume
which tells mij cannot invoer name api .
So I’m at a position where, I either do the haphazard invoer __main__ which I don’t like at all, or have to stir the api to a different verkeersopstopping, which I also dislike because it would pauze the intended structure of:
which, despite __init__.py files that have to be everywhere along the chain, is relatively elementary to work with. An api.py somewhere would mean that, to maintain simpleness, I’d have to budge mainscript.py and api.py into their own subdirectory and have a calling script where mainscript.py used to be (a python script, to keep things lightly cross-platform, but that just adds another script to the chain). I want to keep everything ordinary and evident, which is why I’d choose to have the elementary api within the master caller script.
Te summary: What is the recommended, if any, way to uitvoer an api object from a calling script to called scripts? Is this treatment to exporting an api wrong?