Python Module identifies as dict -
lets have lot of key-pair data. have data in package can imported. there way make modules work dicts, performance , extendibility reasons?
example:
common/pairs/ ├── buildings.py └── __init__.py import buildings buildings["foo"] == "bar"
note: desired result can archived putting declaring buildings
in __init__.py
compiled every time, not drag , undroppable, , seems ugly.
is there way achieve well? there way achieve @ all?
not recommend it, can assign dict
sys.modules
. python doesn't care what's there module object.
# buildings.py sys import modules if __name__ != "__main__": modules[__name__] = {'a': 1, 'b': 2, ...}
Comments
Post a Comment