Alright, I guess this is the point to do some re-structuring.
I guess I will use the “commons” strategy that is mentioned in the Python literature: put a lot of
from assets import ThisAsset
myasset = ThisAsset
stuff in a file named commons.py.
Then, in other files, use
import commons
commons.myasset.doStuff()
In the past I thought this would get me circular imports, but I guess doing it right (this time) will avoid them.
Still, I got a question. Right not, I got a lot of stuff in the init functions, like in the Environment class. So, that’s visible stuff depending on a lot of output from the outside.
When I do
# commons.py
from assets import ThisAsset # this is a class with a lot in it's __init__()
myasset = ThisAsset
the instanced class remains “dead”, i.e. init does not get executed, which in my case is good. So, later I would do
# game.py
import commons
commons.myasset()
to “execute” the ThisAsset class, thus calling it’s init. Or, should I clean up all my init’s, moving the stuff in a buildXYZ function?
# commons.py
from assets import ThisAsset # this is a class with an empty __init__()
myasset = ThisAsset() # will execute empty __init__()
# game.py
import commons
commons.myasset.buildAsset()
In the past I tried that, but abonded it for some reason. I think it was too hard to manage the variables required by the (empty) init() function vs. the buildAsset() function.
Any ideas?