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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

asp.net - Configuring WCF Services in Code WCF 4.5 -